Skip to content

Commit 64701b2

Browse files
androm3datopperc
andcommitted
[Hexagon] Explicitly truncate constant in UAddSubO
After llvm#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.com> Fixes llvm#127296
1 parent 256145b commit 64701b2

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3273,7 +3273,7 @@ HexagonTargetLowering::LowerUAddSubO(SDValue Op, SelectionDAG &DAG) const {
32733273
if (Opc == ISD::USUBO) {
32743274
SDValue Op = DAG.getNode(ISD::SUB, dl, VTs.VTs[0], {X, Y});
32753275
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);
32773277
return DAG.getMergeValues({Op, Ov}, dl);
32783278
}
32793279
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -mtriple=hexagon -O0 < %s | FileCheck %s
2+
; REQUIRES: asserts
3+
4+
target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
5+
target triple = "hexagon-unknown-linux4.19.0-musl"
6+
7+
; CHECK: r0 = #-1
8+
9+
define fastcc void @os.linux.tls.initStatic() {
10+
%1 = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 0, i32 1)
11+
br label %2
12+
13+
2: ; preds = %0
14+
%3 = extractvalue { i32, i1 } %1, 0
15+
ret void
16+
}
17+
18+
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
19+
declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) #0
20+
21+
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
22+

0 commit comments

Comments
 (0)