[llvm] 1324ea1 - [WebAssembly] Fold any/alltrue SIMD boolean reductions with eqz (#184704)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 15:54:29 PDT 2026
Author: Derek Schuff
Date: 2026-03-09T22:54:25Z
New Revision: 1324ea1b229919310f54c032f7b30c770bce8a3c
URL: https://github.com/llvm/llvm-project/commit/1324ea1b229919310f54c032f7b30c770bce8a3c
DIFF: https://github.com/llvm/llvm-project/commit/1324ea1b229919310f54c032f7b30c770bce8a3c.diff
LOG: [WebAssembly] Fold any/alltrue SIMD boolean reductions with eqz (#184704)
Existing ISel patterns match setne/seteq following SIMD boolean reductions
any_true and all_true, and drop the ones that are redundant (because the
reductions always return 1 or 0). This adds patterns to also produce eqz
instructions instead of a comparison with a const.
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-memcmp.ll
llvm/test/CodeGen/WebAssembly/simd-reductions.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index f6b1985f39f66..cd65f94fe5937 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -999,7 +999,9 @@ defvar inst = !cast<NI>(reduction[1]);
defvar vec = !cast<Vec>(reduction[2]);
def : Pat<(i32 (and (i32 (intrinsic (vec.vt V128:$x))), (i32 1))), (inst $x)>;
def : Pat<(i32 (setne (i32 (intrinsic (vec.vt V128:$x))), (i32 0))), (inst $x)>;
+def : Pat<(i32 (setne (i32 (intrinsic (vec.vt V128:$x))), (i32 1))), (i32 (EQZ_I32 (inst $x)))>;
def : Pat<(i32 (seteq (i32 (intrinsic (vec.vt V128:$x))), (i32 1))), (inst $x)>;
+def : Pat<(i32 (seteq (i32 (intrinsic (vec.vt V128:$x))), (i32 0))), (i32 (EQZ_I32 (inst $x)))>;
}
multiclass SIMDBitmask<Vec vec, bits<32> simdop> {
diff --git a/llvm/test/CodeGen/WebAssembly/simd-memcmp.ll b/llvm/test/CodeGen/WebAssembly/simd-memcmp.ll
index 7756bad16f951..7da1bd5ed31ba 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-memcmp.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-memcmp.ll
@@ -17,8 +17,7 @@ define i1 @memcmp_zero(ptr %d) {
; CHECK-NEXT: i32.const 0
; CHECK-NEXT: v128.load 0:p2align=0
; CHECK-NEXT: v128.any_true
-; CHECK-NEXT: i32.const 1
-; CHECK-NEXT: i32.ne
+; CHECK-NEXT: i32.eqz
; CHECK-NEXT: # fallthrough-return
entry:
call void @llvm.memset.p0.i32(ptr %d, i8 0, i32 16, i1 false)
diff --git a/llvm/test/CodeGen/WebAssembly/simd-reductions.ll b/llvm/test/CodeGen/WebAssembly/simd-reductions.ll
index 2fbcec3a779a2..959f43ce44e5a 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-reductions.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-reductions.ll
@@ -22,22 +22,46 @@ define i32 @any_v16i8_trunc(<16 x i8> %x) {
ret i32 %c
}
-; CHECK-LABEL: any_v16i8_ne:
-; CHECK-NEXT: .functype any_v16i8_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v16i8_ne_0:
+; CHECK-NEXT: .functype any_v16i8_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v16i8_ne(<16 x i8> %x) {
+define i32 @any_v16i8_ne_0(<16 x i8> %x) {
%a = call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: any_v16i8_eq:
-; CHECK-NEXT: .functype any_v16i8_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v16i8_ne_1:
+; CHECK-NEXT: .functype any_v16i8_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v16i8_ne_1(<16 x i8> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v16i8_eq_0:
+; CHECK-NEXT: .functype any_v16i8_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v16i8_eq_0(<16 x i8> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v16i8_eq_1:
+; CHECK-NEXT: .functype any_v16i8_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v16i8_eq(<16 x i8> %x) {
+define i32 @any_v16i8_eq_1(<16 x i8> %x) {
%a = call i32 @llvm.wasm.anytrue.v16i8(<16 x i8> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
@@ -55,28 +79,53 @@ define i32 @all_v16i8_trunc(<16 x i8> %x) {
ret i32 %c
}
-; CHECK-LABEL: all_v16i8_ne:
-; CHECK-NEXT: .functype all_v16i8_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v16i8_ne_0:
+; CHECK-NEXT: .functype all_v16i8_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: i8x16.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v16i8_ne(<16 x i8> %x) {
+define i32 @all_v16i8_ne_0(<16 x i8> %x) {
%a = call i32 @llvm.wasm.alltrue.v16i8(<16 x i8> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: all_v16i8_eq:
-; CHECK-NEXT: .functype all_v16i8_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v16i8_ne_1:
+; CHECK-NEXT: .functype all_v16i8_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: i8x16.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v16i8_ne_1(<16 x i8> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v16i8(<16 x i8> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v16i8_eq_0:
+; CHECK-NEXT: .functype all_v16i8_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: i8x16.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v16i8_eq_0(<16 x i8> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v16i8(<16 x i8> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v16i8_eq_1:
+; CHECK-NEXT: .functype all_v16i8_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: i8x16.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v16i8_eq(<16 x i8> %x) {
+define i32 @all_v16i8_eq_1(<16 x i8> %x) {
%a = call i32 @llvm.wasm.alltrue.v16i8(<16 x i8> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
ret i32 %c
}
+
; ==============================================================================
; 8 x i16
; ==============================================================================
@@ -94,22 +143,46 @@ define i32 @any_v8i16_trunc(<8 x i16> %x) {
ret i32 %c
}
-; CHECK-LABEL: any_v8i16_ne:
-; CHECK-NEXT: .functype any_v8i16_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v8i16_ne_0:
+; CHECK-NEXT: .functype any_v8i16_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v8i16_ne(<8 x i16> %x) {
+define i32 @any_v8i16_ne_0(<8 x i16> %x) {
%a = call i32 @llvm.wasm.anytrue.v8i16(<8 x i16> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: any_v8i16_eq:
-; CHECK-NEXT: .functype any_v8i16_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v8i16_ne_1:
+; CHECK-NEXT: .functype any_v8i16_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v8i16_ne_1(<8 x i16> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v8i16(<8 x i16> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v8i16_eq_0:
+; CHECK-NEXT: .functype any_v8i16_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v8i16_eq_0(<8 x i16> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v8i16(<8 x i16> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v8i16_eq_1:
+; CHECK-NEXT: .functype any_v8i16_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v8i16_eq(<8 x i16> %x) {
+define i32 @any_v8i16_eq_1(<8 x i16> %x) {
%a = call i32 @llvm.wasm.anytrue.v8i16(<8 x i16> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
@@ -127,28 +200,53 @@ define i32 @all_v8i16_trunc(<8 x i16> %x) {
ret i32 %c
}
-; CHECK-LABEL: all_v8i16_ne:
-; CHECK-NEXT: .functype all_v8i16_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v8i16_ne_0:
+; CHECK-NEXT: .functype all_v8i16_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: i16x8.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v8i16_ne(<8 x i16> %x) {
+define i32 @all_v8i16_ne_0(<8 x i16> %x) {
%a = call i32 @llvm.wasm.alltrue.v8i16(<8 x i16> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: all_v8i16_eq:
-; CHECK-NEXT: .functype all_v8i16_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v8i16_ne_1:
+; CHECK-NEXT: .functype all_v8i16_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: i16x8.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v8i16_ne_1(<8 x i16> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v8i16(<8 x i16> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v8i16_eq_0:
+; CHECK-NEXT: .functype all_v8i16_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: i16x8.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v8i16_eq_0(<8 x i16> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v8i16(<8 x i16> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v8i16_eq_1:
+; CHECK-NEXT: .functype all_v8i16_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: i16x8.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v8i16_eq(<8 x i16> %x) {
+define i32 @all_v8i16_eq_1(<8 x i16> %x) {
%a = call i32 @llvm.wasm.alltrue.v8i16(<8 x i16> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
ret i32 %c
}
+
; ==============================================================================
; 4 x i32
; ==============================================================================
@@ -166,22 +264,46 @@ define i32 @any_v4i32_trunc(<4 x i32> %x) {
ret i32 %c
}
-; CHECK-LABEL: any_v4i32_ne:
-; CHECK-NEXT: .functype any_v4i32_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v4i32_ne_0:
+; CHECK-NEXT: .functype any_v4i32_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v4i32_ne(<4 x i32> %x) {
+define i32 @any_v4i32_ne_0(<4 x i32> %x) {
%a = call i32 @llvm.wasm.anytrue.v4i32(<4 x i32> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: any_v4i32_eq:
-; CHECK-NEXT: .functype any_v4i32_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v4i32_ne_1:
+; CHECK-NEXT: .functype any_v4i32_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v4i32_ne_1(<4 x i32> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v4i32(<4 x i32> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v4i32_eq_0:
+; CHECK-NEXT: .functype any_v4i32_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v4i32_eq_0(<4 x i32> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v4i32(<4 x i32> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v4i32_eq_1:
+; CHECK-NEXT: .functype any_v4i32_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v4i32_eq(<4 x i32> %x) {
+define i32 @any_v4i32_eq_1(<4 x i32> %x) {
%a = call i32 @llvm.wasm.anytrue.v4i32(<4 x i32> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
@@ -199,28 +321,53 @@ define i32 @all_v4i32_trunc(<4 x i32> %x) {
ret i32 %c
}
-; CHECK-LABEL: all_v4i32_ne:
-; CHECK-NEXT: .functype all_v4i32_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v4i32_ne_0:
+; CHECK-NEXT: .functype all_v4i32_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: i32x4.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v4i32_ne(<4 x i32> %x) {
+define i32 @all_v4i32_ne_0(<4 x i32> %x) {
%a = call i32 @llvm.wasm.alltrue.v4i32(<4 x i32> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: all_v4i32_eq:
-; CHECK-NEXT: .functype all_v4i32_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v4i32_ne_1:
+; CHECK-NEXT: .functype all_v4i32_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: i32x4.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v4i32_ne_1(<4 x i32> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v4i32(<4 x i32> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v4i32_eq_0:
+; CHECK-NEXT: .functype all_v4i32_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: i32x4.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v4i32_eq_0(<4 x i32> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v4i32(<4 x i32> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v4i32_eq_1:
+; CHECK-NEXT: .functype all_v4i32_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: i32x4.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v4i32_eq(<4 x i32> %x) {
+define i32 @all_v4i32_eq_1(<4 x i32> %x) {
%a = call i32 @llvm.wasm.alltrue.v4i32(<4 x i32> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
ret i32 %c
}
+
; ==============================================================================
; 2 x i64
; ==============================================================================
@@ -238,22 +385,46 @@ define i32 @any_v2i64_trunc(<2 x i64> %x) {
ret i32 %c
}
-; CHECK-LABEL: any_v2i64_ne:
-; CHECK-NEXT: .functype any_v2i64_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v2i64_ne_0:
+; CHECK-NEXT: .functype any_v2i64_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v2i64_ne(<2 x i64> %x) {
+define i32 @any_v2i64_ne_0(<2 x i64> %x) {
%a = call i32 @llvm.wasm.anytrue.v2i64(<2 x i64> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: any_v2i64_eq:
-; CHECK-NEXT: .functype any_v2i64_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: any_v2i64_ne_1:
+; CHECK-NEXT: .functype any_v2i64_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v2i64_ne_1(<2 x i64> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v2i64(<2 x i64> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v2i64_eq_0:
+; CHECK-NEXT: .functype any_v2i64_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: v128.any_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @any_v2i64_eq_0(<2 x i64> %x) {
+ %a = call i32 @llvm.wasm.anytrue.v2i64(<2 x i64> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: any_v2i64_eq_1:
+; CHECK-NEXT: .functype any_v2i64_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: v128.any_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @any_v2i64_eq(<2 x i64> %x) {
+define i32 @any_v2i64_eq_1(<2 x i64> %x) {
%a = call i32 @llvm.wasm.anytrue.v2i64(<2 x i64> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
@@ -271,22 +442,46 @@ define i32 @all_v2i64_trunc(<2 x i64> %x) {
ret i32 %c
}
-; CHECK-LABEL: all_v2i64_ne:
-; CHECK-NEXT: .functype all_v2i64_ne (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v2i64_ne_0:
+; CHECK-NEXT: .functype all_v2i64_ne_0 (v128) -> (i32){{$}}
; CHECK-NEXT: i64x2.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v2i64_ne(<2 x i64> %x) {
+define i32 @all_v2i64_ne_0(<2 x i64> %x) {
%a = call i32 @llvm.wasm.alltrue.v2i64(<2 x i64> %x)
%b = icmp ne i32 %a, 0
%c = zext i1 %b to i32
ret i32 %c
}
-; CHECK-LABEL: all_v2i64_eq:
-; CHECK-NEXT: .functype all_v2i64_eq (v128) -> (i32){{$}}
+; CHECK-LABEL: all_v2i64_ne_1:
+; CHECK-NEXT: .functype all_v2i64_ne_1 (v128) -> (i32){{$}}
+; CHECK-NEXT: i64x2.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v2i64_ne_1(<2 x i64> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v2i64(<2 x i64> %x)
+ %b = icmp ne i32 %a, 1
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v2i64_eq_0:
+; CHECK-NEXT: .functype all_v2i64_eq_0 (v128) -> (i32){{$}}
+; CHECK-NEXT: i64x2.all_true $push[[T:[0-9]+]]=, $0{{$}}
+; CHECK-NEXT: i32.eqz $push[[R:[0-9]+]]=, $pop[[T]]{{$}}
+; CHECK-NEXT: return $pop[[R]]{{$}}
+define i32 @all_v2i64_eq_0(<2 x i64> %x) {
+ %a = call i32 @llvm.wasm.alltrue.v2i64(<2 x i64> %x)
+ %b = icmp eq i32 %a, 0
+ %c = zext i1 %b to i32
+ ret i32 %c
+}
+
+; CHECK-LABEL: all_v2i64_eq_1:
+; CHECK-NEXT: .functype all_v2i64_eq_1 (v128) -> (i32){{$}}
; CHECK-NEXT: i64x2.all_true $push[[R:[0-9]+]]=, $0{{$}}
; CHECK-NEXT: return $pop[[R]]{{$}}
-define i32 @all_v2i64_eq(<2 x i64> %x) {
+define i32 @all_v2i64_eq_1(<2 x i64> %x) {
%a = call i32 @llvm.wasm.alltrue.v2i64(<2 x i64> %x)
%b = icmp eq i32 %a, 1
%c = zext i1 %b to i32
More information about the llvm-commits
mailing list