Skip to content

Commit 9396c3e

Browse files
committed
[AArch64][SVE] Remove assertion/range check for i16 values during immediate selection
The assertion can fail in some cases when an i16 constant is promoted to i32. e.g. in the added test case the value `i16 -32768` is within the range of i16 but the assert fails when the constant is promoted to positive `i32 32768` by an earlier call to DAG.getConstant(). Differential Revision: https://reviews.llvm.org/D107880 Change-Id: I2f6179783cbc9630e6acab149a762b43c65664de
1 parent 9f4b130 commit 9396c3e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3152,7 +3152,6 @@ bool AArch64DAGToDAGISel::SelectSVEAddSubImm(SDValue N, MVT VT, SDValue &Imm, SD
31523152
Imm = CurDAG->getTargetConstant(ImmVal, DL, MVT::i32);
31533153
return true;
31543154
} else if ((ImmVal & 0xFF) == 0) {
3155-
assert((ImmVal >= -32768) && (ImmVal <= 32512));
31563155
Shift = CurDAG->getTargetConstant(8, DL, MVT::i32);
31573156
Imm = CurDAG->getTargetConstant((ImmVal >> 8) & 0xFF, DL, MVT::i32);
31583157
return true;

llvm/test/CodeGen/AArch64/sve-int-arith-imm.ll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,4 +800,18 @@ entry:
800800
ret <vscale x 4 x i32> %div
801801
}
802802

803+
;
804+
; UQSUB
805+
;
806+
define <vscale x 8 x i16> @uqsub(<vscale x 8 x i16> %a) {
807+
; CHECK-LABEL: uqsub:
808+
; CHECK: // %bb.0:
809+
; CHECK-NEXT: uqsub z0.h, z0.h, #32768 // =0x8000
810+
; CHECK-NEXT: ret
811+
%cmp = icmp slt <vscale x 8 x i16> %a, shufflevector (<vscale x 8 x i16> insertelement (<vscale x 8 x i16> undef, i16 0, i32 0), <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer)
812+
%sub = xor <vscale x 8 x i16> %a, shufflevector (<vscale x 8 x i16> insertelement (<vscale x 8 x i16> undef, i16 -32768, i32 0), <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer)
813+
%sel = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %sub, <vscale x 8 x i16> shufflevector (<vscale x 8 x i16> insertelement (<vscale x 8 x i16> undef, i16 0, i32 0), <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer)
814+
ret <vscale x 8 x i16> %sel
815+
}
816+
803817
attributes #0 = { minsize }

0 commit comments

Comments
 (0)