[PATCH] D124015: [InstCombine] Don't look through bitcast from vector in collectInsertionElements.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 10:28:23 PDT 2022
craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, lebedev.ri.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added a project: LLVM.
We're making a recursive call here and everything in the function
assumes we're looking at scalars. This would be violated if we
looked through a bitcast from vectors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124015
Files:
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/bitcast.ll
Index: llvm/test/Transforms/InstCombine/bitcast.ll
===================================================================
--- llvm/test/Transforms/InstCombine/bitcast.ll
+++ llvm/test/Transforms/InstCombine/bitcast.ll
@@ -435,8 +435,10 @@
; The bitcast from vector is confusing it.
define <2 x i64> @int2vec_insertion_bitcast_from_vec(i64 %x) {
; CHECK-LABEL: @int2vec_insertion_bitcast_from_vec(
-; CHECK-NEXT: [[TMP1:%.*]] = insertelement <2 x i64> <i64 poison, i64 0>, i64 [[X:%.*]], i64 0
-; CHECK-NEXT: ret <2 x i64> [[TMP1]]
+; CHECK-NEXT: [[A:%.*]] = bitcast i64 [[X:%.*]] to <8 x i8>
+; CHECK-NEXT: [[B:%.*]] = zext <8 x i8> [[A]] to <8 x i16>
+; CHECK-NEXT: [[D:%.*]] = bitcast <8 x i16> [[B]] to <2 x i64>
+; CHECK-NEXT: ret <2 x i64> [[D]]
;
%a = bitcast i64 %x to <8 x i8>
%b = zext <8 x i8> %a to <8 x i16>
Index: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -2271,6 +2271,8 @@
switch (I->getOpcode()) {
default: return false; // Unhandled case.
case Instruction::BitCast:
+ if (I->getOperand(0)->getType()->isVectorTy())
+ return false;
return collectInsertionElements(I->getOperand(0), Shift, Elements, VecEltTy,
isBigEndian);
case Instruction::ZExt:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124015.423664.patch
Type: text/x-patch
Size: 1446 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220419/d6bef877/attachment.bin>
More information about the llvm-commits
mailing list