[llvm] 41b876d - [ValueTracking] Add tests for Known{Bits,NonZero,FPClass} for `llvm.vector.reverse`; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 11:48:31 PDT 2024
Author: Noah Goldstein
Date: 2024-07-17T02:48:09+08:00
New Revision: 41b876dba420d09ba1015798a06b2b101cbb21bf
URL: https://github.com/llvm/llvm-project/commit/41b876dba420d09ba1015798a06b2b101cbb21bf
DIFF: https://github.com/llvm/llvm-project/commit/41b876dba420d09ba1015798a06b2b101cbb21bf.diff
LOG: [ValueTracking] Add tests for Known{Bits,NonZero,FPClass} for `llvm.vector.reverse`; NFC
Added:
llvm/test/Analysis/ValueTracking/known-bits.ll
llvm/test/Analysis/ValueTracking/known-fpclass.ll
Modified:
llvm/test/Analysis/ValueTracking/known-non-zero.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/ValueTracking/known-bits.ll b/llvm/test/Analysis/ValueTracking/known-bits.ll
new file mode 100644
index 0000000000000..9491f2bcf3adf
--- /dev/null
+++ b/llvm/test/Analysis/ValueTracking/known-bits.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=instsimplify < %s -S | FileCheck %s
+
+define <4 x i1> @vec_reverse_known_bits(<4 x i8> %xx) {
+; CHECK-LABEL: @vec_reverse_known_bits(
+; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 -128, i8 -128, i8 -128, i8 -128>
+; CHECK-NEXT: [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]])
+; CHECK-NEXT: [[R:%.*]] = icmp slt <4 x i8> [[REV]], zeroinitializer
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %x = or <4 x i8> %xx, <i8 128, i8 128, i8 128, i8 128>
+ %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
+ %r = icmp slt <4 x i8> %rev, zeroinitializer
+ ret <4 x i1> %r
+}
+
+define <4 x i1> @vec_reverse_known_bits_fail(<4 x i8> %xx) {
+; CHECK-LABEL: @vec_reverse_known_bits_fail(
+; CHECK-NEXT: [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 -128, i8 -128, i8 -128, i8 127>
+; CHECK-NEXT: [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]])
+; CHECK-NEXT: [[R:%.*]] = icmp slt <4 x i8> [[REV]], zeroinitializer
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %x = or <4 x i8> %xx, <i8 128, i8 128, i8 128, i8 127>
+ %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
+ %r = icmp slt <4 x i8> %rev, zeroinitializer
+ ret <4 x i1> %r
+}
diff --git a/llvm/test/Analysis/ValueTracking/known-fpclass.ll b/llvm/test/Analysis/ValueTracking/known-fpclass.ll
new file mode 100644
index 0000000000000..aafdf63ba7770
--- /dev/null
+++ b/llvm/test/Analysis/ValueTracking/known-fpclass.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes=instsimplify < %s -S | FileCheck %s
+
+define <4 x i1> @vector_reverse_fpclass(<4 x double> nofpclass(nzero nan) %x) {
+; CHECK-LABEL: @vector_reverse_fpclass(
+; CHECK-NEXT: [[X_ABS:%.*]] = call <4 x double> @llvm.fabs.v4f64(<4 x double> [[X:%.*]])
+; CHECK-NEXT: [[OP:%.*]] = call <4 x double> @llvm.vector.reverse.v4f64(<4 x double> [[X_ABS]])
+; CHECK-NEXT: [[CMP:%.*]] = fcmp oge <4 x double> [[OP]], zeroinitializer
+; CHECK-NEXT: ret <4 x i1> [[CMP]]
+;
+ %x.abs = call <4 x double> @llvm.fabs.v4f64(<4 x double> %x)
+ %op = call <4 x double> @llvm.vector.reverse(<4 x double> %x.abs)
+ %cmp = fcmp oge <4 x double> %op, <double 0.0, double 0.0, double 0.0, double 0.0>
+ ret <4 x i1> %cmp
+}
+
+define <4 x i1> @vector_reverse_fpclass2(<4 x double> nofpclass(nzero) %x) {
+; CHECK-LABEL: @vector_reverse_fpclass2(
+; CHECK-NEXT: [[X_ABS:%.*]] = call <4 x double> @llvm.fabs.v4f64(<4 x double> [[X:%.*]])
+; CHECK-NEXT: [[OP:%.*]] = call <4 x double> @llvm.vector.reverse.v4f64(<4 x double> [[X_ABS]])
+; CHECK-NEXT: [[CMP:%.*]] = fcmp oge <4 x double> [[OP]], zeroinitializer
+; CHECK-NEXT: ret <4 x i1> [[CMP]]
+;
+ %x.abs = call <4 x double> @llvm.fabs.v4f64(<4 x double> %x)
+ %op = call <4 x double> @llvm.vector.reverse(<4 x double> %x.abs)
+ %cmp = fcmp oge <4 x double> %op, <double 0.0, double 0.0, double 0.0, double 0.0>
+ ret <4 x i1> %cmp
+}
+
diff --git a/llvm/test/Analysis/ValueTracking/known-non-zero.ll b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
index c00e47fba8c72..3e6d1e0860645 100644
--- a/llvm/test/Analysis/ValueTracking/known-non-zero.ll
+++ b/llvm/test/Analysis/ValueTracking/known-non-zero.ll
@@ -1497,4 +1497,30 @@ define i1 @trunc_nsw_nuw_non_zero_fail(i8 %xx) {
ret i1 %r
}
+define <4 x i1> @vec_reverse_non_zero(<4 x i8> %xx) {
+; CHECK-LABEL: @vec_reverse_non_zero(
+; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 1, i8 1, i8 1>
+; CHECK-NEXT: [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[REV]], zeroinitializer
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %x = add nuw <4 x i8> %xx, <i8 1, i8 1, i8 1, i8 1>
+ %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
+ %r = icmp eq <4 x i8> %rev, zeroinitializer
+ ret <4 x i1> %r
+}
+
+define <4 x i1> @vec_reverse_non_zero_fail(<4 x i8> %xx) {
+; CHECK-LABEL: @vec_reverse_non_zero_fail(
+; CHECK-NEXT: [[X:%.*]] = add nuw <4 x i8> [[XX:%.*]], <i8 1, i8 0, i8 1, i8 1>
+; CHECK-NEXT: [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq <4 x i8> [[REV]], zeroinitializer
+; CHECK-NEXT: ret <4 x i1> [[R]]
+;
+ %x = add nuw <4 x i8> %xx, <i8 1, i8 0, i8 1, i8 1>
+ %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
+ %r = icmp eq <4 x i8> %rev, zeroinitializer
+ ret <4 x i1> %r
+}
+
declare i32 @llvm.experimental.get.vector.length.i32(i32, i32, i1)
More information about the llvm-commits
mailing list