[PATCH] D82049: Fix crash in VectorCombine when attempting to peephole ConstantVector sequences
Chang Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 19 10:19:16 PDT 2020
clin1 updated this revision to Diff 272115.
clin1 added a comment.
Thanks for the consensus. New patch uploaded.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82049/new/
https://reviews.llvm.org/D82049
Files:
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
Index: llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
===================================================================
--- llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
+++ llvm/test/Transforms/VectorCombine/X86/insert-binop-with-constant.ll
@@ -726,3 +726,16 @@
%bo = frem nnan <2 x double> %ins, <double 42.0, double -42.0>
ret <2 x double> %bo
}
+
+define i32 @constant_fold_crash(<4 x i32> %x) {
+; CHECK-LABEL: @constant_fold_crash(
+; CHECK-NEXT: [[A:%.*]] = extractelement <4 x i32> <i32 16, i32 17, i32 18, i32 19>, i32 1
+; CHECK-NEXT: [[B:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
+; CHECK-NEXT: [[C:%.*]] = add i32 [[A]], [[B]]
+; CHECK-NEXT: ret i32 [[C]]
+;
+ %a = extractelement <4 x i32> <i32 16, i32 17, i32 18, i32 19>, i32 1
+ %b = extractelement <4 x i32> %x, i32 0
+ %c = add i32 %a, %b
+ ret i32 %c
+}
Index: llvm/lib/Transforms/Vectorize/VectorCombine.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -218,6 +218,10 @@
V0->getType() != V1->getType())
return false;
+ // If either extract can be constant-folded, just leave it for InstSimplify.
+ if (isa<Constant>(Ext0->getOperand(0)) || isa<Constant>(Ext1->getOperand(0)))
+ return false;
+
// If the scalar value 'I' is going to be re-inserted into a vector, then try
// to create an extract to that same element. The extract/insert can be
// reduced to a "select shuffle".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82049.272115.patch
Type: text/x-patch
Size: 1585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200619/4112ff3c/attachment.bin>
More information about the llvm-commits
mailing list