Skip to content

Commit cccff9b

Browse files
goldsteinnGroverkss
authored andcommitted
[VPlan] Preserve IR flags when widening casts
We have `nneg` for both `sext` and `uitofp`. Fixes llvm#114856 Closes llvm#115373
1 parent 6818de2 commit cccff9b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,8 @@ void VPWidenCastRecipe::execute(VPTransformState &State) {
14841484
Value *Cast = Builder.CreateCast(Instruction::CastOps(Opcode), A, DestTy);
14851485
State.set(this, Cast);
14861486
State.addMetadata(Cast, cast_or_null<Instruction>(getUnderlyingValue()));
1487+
if (auto *CastOp = dyn_cast<Instruction>(Cast))
1488+
setFlags(CastOp);
14871489
}
14881490

14891491
InstructionCost VPWidenCastRecipe::computeCost(ElementCount VF,

llvm/test/Transforms/LoopVectorize/uitofp-preserve-nneg.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ define void @uitofp_preserve_nneg(ptr %result, i32 %size, float %y) {
1313
; CHECK-NEXT: [[INDEX1:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
1414
; CHECK-NEXT: [[VEC_IND:%.*]] = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ]
1515
; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[INDEX1]], 0
16-
; CHECK-NEXT: [[TMP0:%.*]] = uitofp <4 x i32> [[VEC_IND]] to <4 x float>
16+
; CHECK-NEXT: [[TMP0:%.*]] = uitofp nneg <4 x i32> [[VEC_IND]] to <4 x float>
1717
; CHECK-NEXT: [[TMP3:%.*]] = fmul <4 x float> [[TMP0]], [[BROADCAST_SPLAT3]]
1818
; CHECK-NEXT: [[INDEX:%.*]] = zext nneg i32 [[TMP1]] to i64
1919
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds float, ptr [[RESULT:%.*]], i64 [[INDEX]]

0 commit comments

Comments
 (0)