Skip to content

Commit

Permalink
Remove left-shift special case
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Mar 13, 2023
1 parent 126a772 commit ea8077f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 2 additions & 8 deletions cranelift/codegen/src/isa/aarch64/lower.isle
Original file line number Diff line number Diff line change
Expand Up @@ -1289,19 +1289,13 @@
(csel (Cond.Ne) lo_lshift maybe_hi)))))

;; Shift for vector types.
(rule -4 (lower (has_type (ty_vec128 ty) (ishl x y)))
(rule -3 (lower (has_type (ty_vec128 ty) (ishl x y)))
(let ((size VectorSize (vector_size ty))
(masked_shift_amt Reg (and_imm $I32 y (shift_mask ty)))
(shift Reg (vec_dup masked_shift_amt size)))
(sshl x shift size)))
(rule -3 (lower (has_type (ty_vec128 ty) (ishl x (iconst (u64_from_imm64 n)))))
(ushl_vec_imm x (shift_masked_imm ty n) (vector_size ty)))

;; If left-shifting by zero don't generate a shift instruction and return the
;; original value
(rule -2 (lower (has_type (ty_vec128 ty) (ishl x (iconst (u64_from_imm64 n)))))
(if-let 0 (shift_masked_imm ty n))
x)
(ushl_vec_imm x (shift_masked_imm ty n) (vector_size ty)))

(decl pure shift_masked_imm (Type u64) u8)
(extern constructor shift_masked_imm shift_masked_imm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ block0(v0: i8x16):

; VCode:
; block0:
; shl v0.16b, v0.16b, #0
; ret
;
; Disassembled:
; block0: ; offset 0x0
; shl v0.16b, v0.16b, #0
; ret

function %ishl_i16x8_full_width(i16x8) -> i16x8 {
Expand All @@ -356,10 +358,12 @@ block0(v0: i16x8):

; VCode:
; block0:
; shl v0.8h, v0.8h, #0
; ret
;
; Disassembled:
; block0: ; offset 0x0
; shl v0.8h, v0.8h, #0
; ret

function %ishl_i32x4_full_width(i32x4) -> i32x4 {
Expand All @@ -371,10 +375,12 @@ block0(v0: i32x4):

; VCode:
; block0:
; shl v0.4s, v0.4s, #0
; ret
;
; Disassembled:
; block0: ; offset 0x0
; shl v0.4s, v0.4s, #0
; ret

function %ishl_i64x2_full_width(i64x2) -> i64x2 {
Expand All @@ -386,10 +392,12 @@ block0(v0: i64x2):

; VCode:
; block0:
; shl v0.2d, v0.2d, #0
; ret
;
; Disassembled:
; block0: ; offset 0x0
; shl v0.2d, v0.2d, #0
; ret

function %sshr_i8x16_full_width(i8x16) -> i8x16 {
Expand Down

0 comments on commit ea8077f

Please sign in to comment.