Skip to content

Commit ef5b1ec

Browse files
committed
[VectorCombine] foldShuffleToIdentity - ensure casts have the same source type
1 parent c16e378 commit ef5b1ec

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,6 +1906,9 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
19061906
if (auto *CI = dyn_cast<CmpInst>(V))
19071907
if (CI->getPredicate() != cast<CmpInst>(FrontV)->getPredicate())
19081908
return false;
1909+
if (auto *CI = dyn_cast<CastInst>(V))
1910+
if (CI->getSrcTy() != cast<CastInst>(FrontV)->getSrcTy())
1911+
return false;
19091912
if (auto *SI = dyn_cast<SelectInst>(V))
19101913
if (!isa<VectorType>(SI->getOperand(0)->getType()) ||
19111914
SI->getOperand(0)->getType() !=

llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,25 @@ define void @maximal_legal_fpmath(ptr %addr1, ptr %addr2, ptr %result, float %va
993993
ret void
994994
}
995995

996+
define void @bitcast_srcty_mismatch() {
997+
; CHECK-LABEL: @bitcast_srcty_mismatch(
998+
; CHECK-NEXT: entry:
999+
; CHECK-NEXT: [[SHUFFLE_I_I:%.*]] = shufflevector <2 x i64> zeroinitializer, <2 x i64> zeroinitializer, <2 x i32> <i32 1, i32 3>
1000+
; CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i32> zeroinitializer to <4 x float>
1001+
; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> [[SHUFFLE_I_I]] to <4 x float>
1002+
; CHECK-NEXT: [[SHUFP_I196:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> [[TMP1]], <4 x i32> <i32 2, i32 1, i32 4, i32 7>
1003+
; CHECK-NEXT: store <4 x float> [[SHUFP_I196]], ptr null, align 16
1004+
; CHECK-NEXT: ret void
1005+
;
1006+
entry:
1007+
%shuffle.i.i = shufflevector <2 x i64> zeroinitializer, <2 x i64> zeroinitializer, <2 x i32> <i32 1, i32 3>
1008+
%0 = bitcast <4 x i32> zeroinitializer to <4 x float>
1009+
%1 = bitcast <2 x i64> %shuffle.i.i to <4 x float>
1010+
%shufp.i196 = shufflevector <4 x float> %0, <4 x float> %1, <4 x i32> <i32 2, i32 1, i32 4, i32 7>
1011+
store <4 x float> %shufp.i196, ptr null, align 16
1012+
ret void
1013+
}
1014+
9961015
define <2 x float> @first_scalar_select(<2 x float> %0, <2 x float> %1, float %x) {
9971016
; CHECK-LABEL: @first_scalar_select(
9981017
; CHECK-NEXT: entry:

0 commit comments

Comments
 (0)