[Hexagon] Explicitly truncate constant in UAddSubO (#127360) · llvm/llvm-project@3dedc99 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 3dedc99

androm3datstellar

authored and

committed

[Hexagon] Explicitly truncate constant in UAddSubO (#127360)

After #117558 landed, this code would assert "Value is not an N-bit unsigned value" in getConstant(), from a test case in zig. Co-authored-by: Craig Topper craig.topper@sifive.comFixes #127296(cherry picked from commit 788cb72)

File tree

2 files changed

lines changed

2 files changed

lines changed

Lines changed: 1 addition & 1 deletion

Original file line number Diff line number Diff line change
@@ -3273,7 +3273,7 @@ HexagonTargetLowering::LowerUAddSubO(SDValue Op, SelectionDAG &DAG) const {
3273 3273 if (Opc == ISD::USUBO) {
3274 3274 SDValue Op = DAG.getNode(ISD::SUB, dl, VTs.VTs[0], {X, Y});
3275 3275 SDValue Ov = DAG.getSetCC(dl, MVT::i1, Op,
3276 - DAG.getConstant(-1, dl, ty(Op)), ISD::SETEQ);
3276 + DAG.getAllOnesConstant(dl, ty(Op)), ISD::SETEQ);
3277 3277 return DAG.getMergeValues({Op, Ov}, dl);
3278 3278 }
3279 3279 }

Lines changed: 18 additions & 0 deletions

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
1 +; RUN: llc -mtriple=hexagon -O0 < %s | FileCheck %s
2 +
3 +; CHECK: r0 = add(r0,#-1)
4 +
5 +define fastcc void @os.linux.tls.initStatic(i32 %x) {
6 +%1 = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %x, i32 1)
7 +br label %2
8 +
9 +2: ; preds = %0
10 +%3 = extractvalue { i32, i1 } %1, 0
11 +ret void
12 +}
13 +
14 +; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
15 +declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) #0
16 +
17 +attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
18 +