A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Fix a bug that caused float bitwise operations to fail on aarch64. (#11811)
Masashi Yoshimura3859a683f5e7
diff --git a/cranelift/codegen/src/isa/aarch64/inst.isle b/cranelift/codegen/src/isa/aarch64/inst.isleindex 2d1eb8f1b2..1c7bc76fdd 100644--- a/cranelift/codegen/src/isa/aarch64/inst.isle+++ b/cranelift/codegen/src/isa/aarch64/inst.isle@@ -1413,6 +1413,12 @@(rule (vector_size (dynamic_lane 32 4)) (VectorSize.Size32x4))(rule (vector_size (dynamic_lane 64 2)) (VectorSize.Size64x2))+;; Helper for converting the `ScalarSize` of a float value to the corresponding `VectorSize`+(decl float_vector_size_in_64 (Type) VectorSize)+(rule (float_vector_size_in_64 $F16) (VectorSize.Size16x4))+(rule (float_vector_size_in_64 $F32) (VectorSize.Size32x2))+(rule (float_vector_size_in_64 $F64) (VectorSize.Size8x8))+;; A floating-point unit (FPU) operation with one arg.(type FPUOp1(enumdiff --git a/cranelift/codegen/src/isa/aarch64/lower.isle b/cranelift/codegen/src/isa/aarch64/lower.isleindex c32edb2b1f..33c06c4c4a 100644--- a/cranelift/codegen/src/isa/aarch64/lower.isle+++ b/cranelift/codegen/src/isa/aarch64/lower.isle@@ -1383,9 +1383,12 @@;;;; Rules for `band` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-(rule band_fits_in_64 -3 (lower (has_type (fits_in_64 ty) (band x y)))+(rule band_fits_in_64 -4 (lower (has_type (fits_in_64 (ty_int ty)) (band x y)))(alu_rs_imm_logic_commutative (ALUOp.And) ty x y))+(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (band x y)))+ (and_vec x y (float_vector_size_in_64 ty)))+;; Implementation of `band` for vector types.(rule -2 (lower (has_type (ty_vec64 ty) (band x y)))(and_vec x y (vector_size ty)))@@ -1417,9 +1420,12 @@;;;; Rules for `bor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-(rule bor_fits_in_64 -3 (lower (has_type (fits_in_64 ty) (bor x y)))+(rule bor_fits_in_64 -4 (lower (has_type (fits_in_64 (ty_int ty)) (bor x y)))(alu_rs_imm_logic_commutative (ALUOp.Orr) ty x y))+(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (bor x y)))+ (orr_vec x y (float_vector_size_in_64 ty)))+;; Implementation of `bor` for vector types.(rule -2 (lower (has_type (ty_vec64 ty) (bor x y)))(orr_vec x y (vector_size ty)))@@ -1472,9 +1478,12 @@;;;; Rules for `bxor` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-(rule bxor_fits_in_64 -3 (lower (has_type (fits_in_64 ty) (bxor x y)))+(rule bxor_fits_in_64 -4 (lower (has_type (fits_in_64 (ty_int ty)) (bxor x y)))(alu_rs_imm_logic_commutative (ALUOp.Eor) ty x y))+(rule -3 (lower (has_type (fits_in_64 (ty_scalar_float ty)) (bxor x y)))+ (eor_vec x y (float_vector_size_in_64 ty)))+;; Implementation of `bxor` for vector types.(rule -2 (lower (has_type (ty_vec64 ty) (bxor x y)))(eor_vec x y (vector_size ty)))diff --git a/cranelift/filetests/filetests/isa/aarch64/floating-point-bitwise.clif b/cranelift/filetests/filetests/isa/aarch64/floating-point-bitwise.clifnew file mode 100644index 0000000000..b0645e470f--- /dev/null+++ b/cranelift/filetests/filetests/isa/aarch64/floating-point-bitwise.clif@@ -0,0 +1,93 @@+test compile precise-output+set unwind_info=false+set preserve_frame_pointers=true+target aarch64++function %f1() -> f64 fast {++block0:+ v1 = f64const 0x1.11044b092d153p-1+ v2 = bxor.f64 v1, v1+ return v2+}++; VCode:+; stp fp, lr, [sp, #-16]!+; mov fp, sp+; block0:+; ldr d1, [const(0)]+; eor v0.8b, v1.8b, v1.8b+; ldp fp, lr, [sp], #16+; ret+;+; Disassembled:+; block0: ; offset 0x0+; stp x29, x30, [sp, #-0x10]!+; mov x29, sp+; block1: ; offset 0x8+; ldr d1, #0x18+; eor v0.8b, v1.8b, v1.8b+; ldp x29, x30, [sp], #0x10+; ret+; adrp x19, #0xffffffff25a29000+; .byte 0x44, 0x10, 0xe1, 0x3f++function %f2() -> f32 fast {++block0:+ v1 = f32const 0x1.11044cp-1+ v2 = bxor.f32 v1, v1+ return v2+}++; VCode:+; stp fp, lr, [sp, #-16]!+; mov fp, sp+; block0:+; movz w2, #33318+; movk w2, w2, #16136, LSL #16+; fmov s5, w2+; eor v0.8b, v5.8b, v5.8b+; ldp fp, lr, [sp], #16+; ret+;+; Disassembled:+; block0: ; offset 0x0+; stp x29, x30, [sp, #-0x10]!+; mov x29, sp+; block1: ; offset 0x8+; mov w2, #0x8226+; movk w2, #0x3f08, lsl #16+; fmov s5, w2+; eor v0.8b, v5.8b, v5.8b+; ldp x29, x30, [sp], #0x10+; ret++function %f3() -> f16 fast {++block0:+ v1 = f16const 0x1.11p-1+ v2 = bxor.f16 v1, v1+ return v2+}++; VCode:+; stp fp, lr, [sp, #-16]!+; mov fp, sp+; block0:+; movz w1, #14404+; fmov s3, w1+; eor v0.8b, v3.8b, v3.8b+; ldp fp, lr, [sp], #16+; ret+;+; Disassembled:+; block0: ; offset 0x0+; stp x29, x30, [sp, #-0x10]!+; mov x29, sp+; block1: ; offset 0x8+; mov w1, #0x3844+; fmov s3, w1+; eor v0.8b, v3.8b, v3.8b+; ldp x29, x30, [sp], #0x10+; ret\ No newline at end of file