Skip to content

Commit

Permalink
Fix 16-bit x86_pextr encoding
Browse files Browse the repository at this point in the history
The x86 ISA has (at least) two encodings for PEXTRW:
 1. in the SSE2 opcode (66 0f c5) the XMM operand uses r/m and the GPR operand uses reg
 2. in the SSE4.1 opcode (66 0f 3a 15) the XMM operand uses reg and the GPR operand uses r/m

This changes the 16-bit x86_pextr encoding from #1 to #2 to match the other PEXTR* implementations (all #2 style).
  • Loading branch information
abrown committed Sep 18, 2019
1 parent 4ab3939 commit c33cb52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cranelift-codegen/meta/src/isa/x86/encodings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1874,8 +1874,8 @@ pub(crate) fn define(
// SIMD extractlane
for (lane_bits, opcode, isap) in [
(8, vec![0x66, 0x0f, 0x3a, 0x14], Some(use_sse41_simd)), // PEXTRB
(16, vec![0x66, 0x0f, 0xc5], None), // PEXTRW from SSE2, SSE4.1 has a PEXTRW that can
// move to reg/m16 but the opcode is four bytes
(16, vec![0x66, 0x0f, 0x3a, 0x15], Some(use_sse41_simd)), // PEXTRW from SSE4.1, SSE2 has a
// PEXTRW that can move to reg/m16 but the ModR/M assignment is backwards
(32, vec![0x66, 0x0f, 0x3a, 0x16], Some(use_sse41_simd)), // PEXTRD
(64, vec![0x66, 0x0f, 0x3a, 0x16], Some(use_sse41_simd)), // PEXTRQ, only x86_64
]
Expand Down
2 changes: 1 addition & 1 deletion filetests/isa/x86/extractlane-binemit.clif
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function %test_extractlane_i16() {
ebb0:
[-, %rax] v0 = iconst.i16 4
[-, %xmm1] v1 = splat.i16x8 v0
[-, %rax] v2 = x86_pextr v1, 4 ; bin: 66 0f c5 c8 04
[-, %rax] v2 = x86_pextr v1, 4 ; bin: 66 0f 3a 15 c8 04
return
}

Expand Down

0 comments on commit c33cb52

Please sign in to comment.