[PATCH] D120439: [SLP] Fix for the min/max intrinsic cost.
Vasileios Porpodas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 23 15:30:12 PST 2022
vporpo created this revision.
vporpo added reviewers: fhahn, ABataev, RKSimon.
Herald added a subscriber: hiraditya.
vporpo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The min/max intrinsic cost is currently underestimated, so an SLP graph
containing it has a good chance of being vectorized even though it may not
be actually profitable.
I think that commit b3b993a7ad817 <https://reviews.llvm.org/rGb3b993a7ad817c3c5801341fa78f34332900eb83> broke this by accident.
https://reviews.llvm.org/rGb3b993a7ad817c3c5801341fa78f34332900eb83
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120439
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/max_intrinsic_cost.ll
Index: llvm/test/Transforms/SLPVectorizer/X86/max_intrinsic_cost.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/max_intrinsic_cost.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/max_intrinsic_cost.ll
@@ -6,13 +6,11 @@
; This maps to a single PMAX instruction in x86.
define void @max_intrinsic_cost(i64 %arg0, i64 %arg1) {
; CHECK-LABEL: @max_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: [[ICMP0:%.*]] = icmp sgt i64 [[ARG0:%.*]], 123
+; CHECK-NEXT: [[ICMP1:%.*]] = icmp sgt 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 sgt i64 %arg0, 123
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5125,9 +5125,7 @@
// If the selects are the only uses of the compares, they will be dead
// and we can adjust the cost by removing their cost.
if (IntrinsicAndUse.second)
- IntrinsicCost -=
- TTI->getCmpSelInstrCost(Instruction::ICmp, VecTy, MaskTy,
- CmpInst::BAD_ICMP_PREDICATE, CostKind);
+ IntrinsicCost -= VecCost;
VecCost = std::min(VecCost, IntrinsicCost);
}
LLVM_DEBUG(dumpTreeCosts(E, CommonCost, VecCost, ScalarCost));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120439.410958.patch
Type: text/x-patch
Size: 2203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220223/affd7df8/attachment.bin>
More information about the llvm-commits
mailing list