Skip to content

Commit 8ad354c

Browse files
committed
IsSingleScalar
1 parent 6ad25c5 commit 8ad354c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ bool vputils::isSingleScalar(const VPValue *VPV) {
171171
return PreservesUniformity(WidenR->getOpcode()) &&
172172
all_of(WidenR->operands(), isSingleScalar);
173173
}
174+
if (auto *CastR = dyn_cast<VPWidenCastRecipe>(VPV)) {
175+
return PreservesUniformity(CastR->getOpcode()) &&
176+
all_of(CastR->operands(), isSingleScalar);
177+
}
174178
if (auto *VPI = dyn_cast<VPInstruction>(VPV))
175179
return VPI->isSingleScalar() || VPI->isVectorToScalar() ||
176180
(PreservesUniformity(VPI->getOpcode()) &&

llvm/test/Transforms/LoopVectorize/single-scalar-cast-minbw.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ define void @minbw_cast(ptr %dst, i64 %n, i1 %bool1, i1 %bool2) {
1818
; CHECK-NEXT: [[BROADCAST_SPLAT2:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT1]], <4 x i32> poison, <4 x i32> zeroinitializer
1919
; CHECK-NEXT: [[TMP0:%.*]] = trunc <4 x i32> [[BROADCAST_SPLAT2]] to <4 x i8>
2020
; CHECK-NEXT: [[TMP1:%.*]] = zext <4 x i1> [[BROADCAST_SPLAT]] to <4 x i8>
21-
; CHECK-NEXT: [[TMP2:%.*]] = xor <4 x i8> [[TMP0]], [[TMP1]]
22-
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i8> [[TMP2]], i32 3
21+
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i8> [[TMP0]], i32 0
22+
; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x i8> [[TMP1]], i32 0
23+
; CHECK-NEXT: [[TMP3:%.*]] = xor i8 [[TMP2]], [[TMP5]]
2324
; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
2425
; CHECK: [[VECTOR_BODY]]:
2526
; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]

0 commit comments

Comments
 (0)