[llvm] ef5b1ec - [VectorCombine] foldShuffleToIdentity - ensure casts have the same source type
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 05:11:16 PDT 2024
Author: Simon Pilgrim
Date: 2024-07-09T13:10:11+01:00
New Revision: ef5b1ec0dd0ed39de5ac5df6f9e3052d359733ae
URL: https://github.com/llvm/llvm-project/commit/ef5b1ec0dd0ed39de5ac5df6f9e3052d359733ae
DIFF: https://github.com/llvm/llvm-project/commit/ef5b1ec0dd0ed39de5ac5df6f9e3052d359733ae.diff
LOG: [VectorCombine] foldShuffleToIdentity - ensure casts have the same source type
Added:
Modified:
llvm/lib/Transforms/Vectorize/VectorCombine.cpp
llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index ebef29e8be206..4896b8ed2595b 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -1906,6 +1906,9 @@ bool VectorCombine::foldShuffleToIdentity(Instruction &I) {
if (auto *CI = dyn_cast<CmpInst>(V))
if (CI->getPredicate() != cast<CmpInst>(FrontV)->getPredicate())
return false;
+ if (auto *CI = dyn_cast<CastInst>(V))
+ if (CI->getSrcTy() != cast<CastInst>(FrontV)->getSrcTy())
+ return false;
if (auto *SI = dyn_cast<SelectInst>(V))
if (!isa<VectorType>(SI->getOperand(0)->getType()) ||
SI->getOperand(0)->getType() !=
diff --git a/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll b/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll
index 7ca5baf3b538a..a2c82ddd19480 100644
--- a/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll
+++ b/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll
@@ -993,6 +993,25 @@ define void @maximal_legal_fpmath(ptr %addr1, ptr %addr2, ptr %result, float %va
ret void
}
+define void @bitcast_srcty_mismatch() {
+; CHECK-LABEL: @bitcast_srcty_mismatch(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SHUFFLE_I_I:%.*]] = shufflevector <2 x i64> zeroinitializer, <2 x i64> zeroinitializer, <2 x i32> <i32 1, i32 3>
+; CHECK-NEXT: [[TMP0:%.*]] = bitcast <4 x i32> zeroinitializer to <4 x float>
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> [[SHUFFLE_I_I]] to <4 x float>
+; CHECK-NEXT: [[SHUFP_I196:%.*]] = shufflevector <4 x float> [[TMP0]], <4 x float> [[TMP1]], <4 x i32> <i32 2, i32 1, i32 4, i32 7>
+; CHECK-NEXT: store <4 x float> [[SHUFP_I196]], ptr null, align 16
+; CHECK-NEXT: ret void
+;
+entry:
+ %shuffle.i.i = shufflevector <2 x i64> zeroinitializer, <2 x i64> zeroinitializer, <2 x i32> <i32 1, i32 3>
+ %0 = bitcast <4 x i32> zeroinitializer to <4 x float>
+ %1 = bitcast <2 x i64> %shuffle.i.i to <4 x float>
+ %shufp.i196 = shufflevector <4 x float> %0, <4 x float> %1, <4 x i32> <i32 2, i32 1, i32 4, i32 7>
+ store <4 x float> %shufp.i196, ptr null, align 16
+ ret void
+}
+
define <2 x float> @first_scalar_select(<2 x float> %0, <2 x float> %1, float %x) {
; CHECK-LABEL: @first_scalar_select(
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list