[llvm] 6136f97 - [SLP][NFC] Test for a follow-up fix of the the vector min/max instrinsic cost calculation.

Vasileios Porpodas via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 24 18:29:18 PST 2022


Author: Vasileios Porpodas
Date: 2022-02-24T18:08:39-08:00
New Revision: 6136f97c69ad06718fc2c335b94ed5abbcb4bb9c

URL: https://github.com/llvm/llvm-project/commit/6136f97c69ad06718fc2c335b94ed5abbcb4bb9c
DIFF: https://github.com/llvm/llvm-project/commit/6136f97c69ad06718fc2c335b94ed5abbcb4bb9c.diff

LOG: [SLP][NFC] Test for a follow-up fix of the the vector min/max instrinsic cost calculation.

The code in this test should not have been vectorized.
It looks worse than the scalar code.

Differential Revision: https://reviews.llvm.org/D120438

Added: 
    llvm/test/Transforms/SLPVectorizer/X86/arith-max-cost.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/arith-max-cost.ll b/llvm/test/Transforms/SLPVectorizer/X86/arith-max-cost.ll
new file mode 100644
index 000000000000..ead647de9e8d
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/arith-max-cost.ll
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -slp-vectorizer -mcpu=corei7-avx -mtriple=x86_64-unknown-linux -S | FileCheck %s
+
+; This test checks whether the cost of the vector max intrinsic is calculated
+; correctly. A max vector intrinsic combines the select and icmp instructions.
+; This maps to a single PMAX instruction in x86.
+define void @smax_intrinsic_cost(i64 %arg0, i64 %arg1) {
+; CHECK-LABEL: @smax_intrinsic_cost(
+; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <2 x i64> poison, i64 [[ARG0:%.*]], i32 0
+; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <2 x i64> [[TMP1]], i64 [[ARG1:%.*]], i32 1
+; CHECK-NEXT:    [[TMP3:%.*]] = icmp sgt <2 x i64> [[TMP2]], <i64 123, i64 456>
+; CHECK-NEXT:    [[TMP4:%.*]] = select <2 x i1> [[TMP3]], <2 x i64> [[TMP2]], <2 x i64> <i64 123, i64 456>
+; CHECK-NEXT:    [[TMP5:%.*]] = extractelement <2 x i64> [[TMP4]], i32 0
+; CHECK-NEXT:    [[TMP6:%.*]] = extractelement <2 x i64> [[TMP4]], i32 1
+; CHECK-NEXT:    [[ROOT:%.*]] = icmp sle i64 [[TMP5]], [[TMP6]]
+; CHECK-NEXT:    ret void
+;
+  %icmp0 = icmp sgt i64 %arg0, 123
+  %icmp1 = icmp sgt i64 %arg1, 456
+  %select0 = select i1 %icmp0, i64 %arg0, i64 123
+  %select1 = select i1 %icmp1, i64 %arg1, i64 456
+  %root = icmp sle i64 %select0, %select1
+  ret void
+}
+
+
+define void @umax_intrinsic_cost(i64 %arg0, i64 %arg1) {
+; CHECK-LABEL: @umax_intrinsic_cost(
+; CHECK-NEXT:    [[ICMP0:%.*]] = icmp ugt i64 [[ARG0:%.*]], 123
+; CHECK-NEXT:    [[ICMP1:%.*]] = icmp ugt i64 [[ARG1:%.*]], 456
+; CHECK-NEXT:    [[SELECT0:%.*]] = select i1 [[ICMP0]], i64 [[ARG0]], i64 123
+; CHECK-NEXT:    [[SELECT1:%.*]] = select i1 [[ICMP1]], i64 [[ARG1]], i64 456
+; CHECK-NEXT:    [[ROOT:%.*]] = icmp sle i64 [[SELECT0]], [[SELECT1]]
+; CHECK-NEXT:    ret void
+;
+  %icmp0 = icmp ugt i64 %arg0, 123
+  %icmp1 = icmp ugt i64 %arg1, 456
+  %select0 = select i1 %icmp0, i64 %arg0, i64 123
+  %select1 = select i1 %icmp1, i64 %arg1, i64 456
+  %root = icmp sle i64 %select0, %select1
+  ret void
+}


        


More information about the llvm-commits mailing list