[llvm] 7820518 - [InstCombine][NFC]Add a test for logical reductions.

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 10:09:03 PST 2021


Author: Alexey Bataev
Date: 2021-02-26T10:08:48-08:00
New Revision: 7820518d55f9c40cd55adbe7185743e1bd2c936d

URL: https://github.com/llvm/llvm-project/commit/7820518d55f9c40cd55adbe7185743e1bd2c936d
DIFF: https://github.com/llvm/llvm-project/commit/7820518d55f9c40cd55adbe7185743e1bd2c936d.diff

LOG: [InstCombine][NFC]Add a test for logical reductions.

Added: 
    llvm/test/Transforms/InstCombine/vector-logical-reductions.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/vector-logical-reductions.ll b/llvm/test/Transforms/InstCombine/vector-logical-reductions.ll
new file mode 100644
index 000000000000..f90a7c21fc8c
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/vector-logical-reductions.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+define float @reduction_logical_or(<4 x float> %x) {
+; CHECK-LABEL: @reduction_logical_or(
+; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ogt <4 x float> [[X:%.*]], <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
+; CHECK-NEXT:    [[TMP2:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP1]])
+; CHECK-NEXT:    [[R:%.*]] = select i1 [[TMP2]], float -1.000000e+00, float 1.000000e+00
+; CHECK-NEXT:    ret float [[R]]
+;
+  %1 = fcmp ogt <4 x float> %x, <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
+  %2 = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> %1)
+  %r = select i1 %2, float -1.000000e+00, float 1.000000e+00
+  ret float %r
+}
+
+define float @reduction_logical_and(<4 x float> %x) {
+; CHECK-LABEL: @reduction_logical_and(
+; CHECK-NEXT:    [[TMP1:%.*]] = fcmp ogt <4 x float> [[X:%.*]], <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
+; CHECK-NEXT:    [[TMP2:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP1]])
+; CHECK-NEXT:    [[R:%.*]] = select i1 [[TMP2]], float -1.000000e+00, float 1.000000e+00
+; CHECK-NEXT:    ret float [[R]]
+;
+  %1 = fcmp ogt <4 x float> %x, <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>
+  %2 = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> %1)
+  %r = select i1 %2, float -1.000000e+00, float 1.000000e+00
+  ret float %r
+}
+
+declare i1 @llvm.vector.reduce.or.v4i1(<4 x i1>)
+declare i1 @llvm.vector.reduce.and.v4i1(<4 x i1>)


        


More information about the llvm-commits mailing list