[llvm] [SelectionDAG] Preserve demanded lanes in sign-bit queries (PR #230093)
Tim Gymnich via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 11:10:52 PDT 2026
https://github.com/tgymnich updated https://github.com/llvm/llvm-project/pull/230093
>From 897eaeae64cccb56a7f8053da009a439427c48ae Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tim at gymni.ch>
Date: Thu, 8 Oct 2026 12:08:39 +0000
Subject: [PATCH 1/3] [SelectionDAG] Preserve demanded lanes in sign-bit
queries
Forward demanded lanes through multiplication and truncation.
---
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 7bd01594d394b..b05c63fd59218 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5353,10 +5353,12 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
return std::min(Tmp, Tmp2) - 1;
case ISD::MUL: {
// The output of the Mul can be at most twice the valid bits in the inputs.
- unsigned SignBitsOp0 = ComputeNumSignBits(Op.getOperand(0), Depth + 1);
+ unsigned SignBitsOp0 =
+ ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
if (SignBitsOp0 == 1)
break;
- unsigned SignBitsOp1 = ComputeNumSignBits(Op.getOperand(1), Depth + 1);
+ unsigned SignBitsOp1 =
+ ComputeNumSignBits(Op.getOperand(1), DemandedElts, Depth + 1);
if (SignBitsOp1 == 1)
break;
unsigned OutValidBits =
@@ -5379,7 +5381,8 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
case ISD::TRUNCATE: {
// Check if the sign bits of source go down as far as the truncated value.
unsigned NumSrcBits = Op.getOperand(0).getScalarValueSizeInBits();
- unsigned NumSrcSignBits = ComputeNumSignBits(Op.getOperand(0), Depth + 1);
+ unsigned NumSrcSignBits =
+ ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
if (NumSrcSignBits > (NumSrcBits - VTBits))
return NumSrcSignBits - (NumSrcBits - VTBits);
break;
>From 775a1d99147a3b8415112de82d7651cbf0375d24 Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tim at gymni.ch>
Date: Thu, 8 Oct 2026 14:10:58 +0000
Subject: [PATCH 2/3] [SelectionDAG] Test demanded lanes in sign-bit queries
Cover multiplication and truncation with individual and combined demanded lanes, including unrestricted lanes.
---
.../AArch64/AArch64SelectionDAGTest.cpp | 42 +++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp b/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
index 9d0f6e8a2b003..50fd296ee747a 100644
--- a/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
+++ b/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
@@ -223,6 +223,48 @@ TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_VASHR) {
EXPECT_EQ(DAG->ComputeNumSignBits(Fr2), 5u);
}
+TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_MUL_DemandedElts) {
+ SDLoc Loc;
+ SDValue LHS = DAG->getRegister(1, MVT::v4i32);
+ SDValue RHS = DAG->getRegister(2, MVT::v4i32);
+ SDValue Zero = DAG->getConstant(0, Loc, MVT::i32);
+ SDValue LHSShift =
+ DAG->getBuildVector(MVT::v4i32, Loc,
+ {DAG->getConstant(28, Loc, MVT::i32),
+ DAG->getConstant(24, Loc, MVT::i32), Zero, Zero});
+ SDValue RHSShift =
+ DAG->getBuildVector(MVT::v4i32, Loc,
+ {DAG->getConstant(26, Loc, MVT::i32),
+ DAG->getConstant(22, Loc, MVT::i32), Zero, Zero});
+ LHS = DAG->getNode(ISD::SRA, Loc, MVT::v4i32, LHS, LHSShift);
+ RHS = DAG->getNode(ISD::SRA, Loc, MVT::v4i32, RHS, RHSShift);
+ SDValue Mul = DAG->getNode(ISD::MUL, Loc, MVT::v4i32, LHS, RHS);
+
+ EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0001)), 23u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0010)), 15u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0011)), 15u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0100)), 1u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Mul), 1u);
+}
+
+TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_TRUNCATE_DemandedElts) {
+ SDLoc Loc;
+ SDValue Src = DAG->getRegister(1, MVT::v4i32);
+ SDValue Zero = DAG->getConstant(0, Loc, MVT::i32);
+ SDValue Shift =
+ DAG->getBuildVector(MVT::v4i32, Loc,
+ {DAG->getConstant(28, Loc, MVT::i32),
+ DAG->getConstant(24, Loc, MVT::i32), Zero, Zero});
+ Src = DAG->getNode(ISD::SRA, Loc, MVT::v4i32, Src, Shift);
+ SDValue Trunc = DAG->getNode(ISD::TRUNCATE, Loc, MVT::v4i16, Src);
+
+ EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0001)), 13u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0010)), 9u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0011)), 9u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0100)), 1u);
+ EXPECT_EQ(DAG->ComputeNumSignBits(Trunc), 1u);
+}
+
TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_SUB) {
SDLoc Loc;
auto IntVT = EVT::getIntegerVT(Context, 8);
>From 1f955f25020dfc0841bf91f98875e5b4b6b22db7 Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tim at gymni.ch>
Date: Sun, 11 Oct 2026 20:08:59 +0200
Subject: [PATCH 3/3] [SelectionDAG] Replace demanded-lane unit tests with IR
coverage
---
.../AArch64/sign-bits-demanded-elts.ll | 224 ++++++++++++++++++
.../AArch64/AArch64SelectionDAGTest.cpp | 42 ----
2 files changed, 224 insertions(+), 42 deletions(-)
create mode 100644 llvm/test/CodeGen/AArch64/sign-bits-demanded-elts.ll
diff --git a/llvm/test/CodeGen/AArch64/sign-bits-demanded-elts.ll b/llvm/test/CodeGen/AArch64/sign-bits-demanded-elts.ll
new file mode 100644
index 0000000000000..65b70d8795a85
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/sign-bits-demanded-elts.ll
@@ -0,0 +1,224 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=aarch64 -verify-machineinstrs < %s | FileCheck %s
+
+; Keep every lane live so extracting a subset queries the vector sign bits.
+
+define i32 @mul_lane0(<4 x i32> %lhs, <4 x i32> %rhs, ptr %out) {
+; CHECK-LABEL: mul_lane0:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI0_0
+; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI0_0]
+; CHECK-NEXT: mov x8, x0
+; CHECK-NEXT: sshl v0.4s, v0.4s, v2.4s
+; CHECK-NEXT: sshl v1.4s, v1.4s, v2.4s
+; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: fmov w1, s0
+; CHECK-NEXT: str q0, [x8]
+; CHECK-NEXT: mov w0, w1
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 29, i32 28, i32 0, i32 0>
+ %rhs.shift = ashr <4 x i32> %rhs, <i32 29, i32 28, i32 0, i32 0>
+ %value = mul <4 x i32> %lhs.shift, %rhs.shift
+ store <4 x i32> %value, ptr %out
+ %selected = extractelement <4 x i32> %value, i32 0
+ %narrow = trunc i32 %selected to i8
+ %result = sext i8 %narrow to i32
+ ret i32 %result
+}
+
+define i32 @mul_lane1(<4 x i32> %lhs, <4 x i32> %rhs, ptr %out) {
+; CHECK-LABEL: mul_lane1:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI1_0
+; CHECK-NEXT: mov x9, x0
+; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI1_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v2.4s
+; CHECK-NEXT: sshl v1.4s, v1.4s, v2.4s
+; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: mov w8, v0.s[1]
+; CHECK-NEXT: str q0, [x9]
+; CHECK-NEXT: mov w0, w8
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 29, i32 28, i32 0, i32 0>
+ %rhs.shift = ashr <4 x i32> %rhs, <i32 29, i32 28, i32 0, i32 0>
+ %value = mul <4 x i32> %lhs.shift, %rhs.shift
+ store <4 x i32> %value, ptr %out
+ %selected = extractelement <4 x i32> %value, i32 1
+ %narrow = trunc i32 %selected to i8
+ %result = sext i8 %narrow to i32
+ ret i32 %result
+}
+
+define i32 @mul_lane2(<4 x i32> %lhs, <4 x i32> %rhs, ptr %out) {
+; CHECK-LABEL: mul_lane2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI2_0
+; CHECK-NEXT: mov x9, x0
+; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI2_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v2.4s
+; CHECK-NEXT: sshl v1.4s, v1.4s, v2.4s
+; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: mov w8, v0.s[2]
+; CHECK-NEXT: str q0, [x9]
+; CHECK-NEXT: sxtb w8, w8
+; CHECK-NEXT: mov w0, w8
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 29, i32 28, i32 0, i32 0>
+ %rhs.shift = ashr <4 x i32> %rhs, <i32 29, i32 28, i32 0, i32 0>
+ %value = mul <4 x i32> %lhs.shift, %rhs.shift
+ store <4 x i32> %value, ptr %out
+ %selected = extractelement <4 x i32> %value, i32 2
+ %narrow = trunc i32 %selected to i8
+ %result = sext i8 %narrow to i32
+ ret i32 %result
+}
+
+define i32 @trunc_lane0(<4 x i32> %lhs, ptr %out) {
+; CHECK-LABEL: trunc_lane0:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI3_0
+; CHECK-NEXT: mov x9, x0
+; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI3_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: xtn v0.4h, v0.4s
+; CHECK-NEXT: smov w8, v0.h[0]
+; CHECK-NEXT: str d0, [x9]
+; CHECK-NEXT: mov w0, w8
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 28, i32 24, i32 0, i32 0>
+ %value = trunc <4 x i32> %lhs.shift to <4 x i16>
+ store <4 x i16> %value, ptr %out
+ %selected = extractelement <4 x i16> %value, i32 0
+ %narrow = trunc i16 %selected to i8
+ %result = sext i8 %narrow to i32
+ ret i32 %result
+}
+
+define i32 @trunc_lane1(<4 x i32> %lhs, ptr %out) {
+; CHECK-LABEL: trunc_lane1:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI4_0
+; CHECK-NEXT: mov x9, x0
+; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI4_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: xtn v0.4h, v0.4s
+; CHECK-NEXT: smov w8, v0.h[1]
+; CHECK-NEXT: str d0, [x9]
+; CHECK-NEXT: mov w0, w8
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 28, i32 24, i32 0, i32 0>
+ %value = trunc <4 x i32> %lhs.shift to <4 x i16>
+ store <4 x i16> %value, ptr %out
+ %selected = extractelement <4 x i16> %value, i32 1
+ %narrow = trunc i16 %selected to i8
+ %result = sext i8 %narrow to i32
+ ret i32 %result
+}
+
+define i32 @trunc_lane2(<4 x i32> %lhs, ptr %out) {
+; CHECK-LABEL: trunc_lane2:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI5_0
+; CHECK-NEXT: mov x9, x0
+; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI5_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: xtn v0.4h, v0.4s
+; CHECK-NEXT: umov w8, v0.h[2]
+; CHECK-NEXT: str d0, [x9]
+; CHECK-NEXT: sxtb w8, w8
+; CHECK-NEXT: mov w0, w8
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 28, i32 24, i32 0, i32 0>
+ %value = trunc <4 x i32> %lhs.shift to <4 x i16>
+ store <4 x i16> %value, ptr %out
+ %selected = extractelement <4 x i16> %value, i32 2
+ %narrow = trunc i16 %selected to i8
+ %result = sext i8 %narrow to i32
+ ret i32 %result
+}
+
+define <2 x i32> @mul_lanes01(<4 x i32> %lhs, <4 x i32> %rhs, ptr %out) {
+; CHECK-LABEL: mul_lanes01:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI6_0
+; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI6_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v2.4s
+; CHECK-NEXT: sshl v1.4s, v1.4s, v2.4s
+; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: str q0, [x0]
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 29, i32 28, i32 0, i32 0>
+ %rhs.shift = ashr <4 x i32> %rhs, <i32 29, i32 28, i32 0, i32 0>
+ %value = mul <4 x i32> %lhs.shift, %rhs.shift
+ store <4 x i32> %value, ptr %out
+ %selected = shufflevector <4 x i32> %value, <4 x i32> poison, <2 x i32> <i32 0, i32 1>
+ %narrow = trunc <2 x i32> %selected to <2 x i8>
+ %result = sext <2 x i8> %narrow to <2 x i32>
+ ret <2 x i32> %result
+}
+
+define <2 x i32> @mul_lanes02(<4 x i32> %lhs, <4 x i32> %rhs, ptr %out) {
+; CHECK-LABEL: mul_lanes02:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI7_0
+; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI7_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v2.4s
+; CHECK-NEXT: sshl v1.4s, v1.4s, v2.4s
+; CHECK-NEXT: mul v1.4s, v0.4s, v1.4s
+; CHECK-NEXT: mov d0, v1.d[1]
+; CHECK-NEXT: str q1, [x0]
+; CHECK-NEXT: zip1 v0.2s, v1.2s, v0.2s
+; CHECK-NEXT: shl v0.2s, v0.2s, #24
+; CHECK-NEXT: sshr v0.2s, v0.2s, #24
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 29, i32 28, i32 0, i32 0>
+ %rhs.shift = ashr <4 x i32> %rhs, <i32 29, i32 28, i32 0, i32 0>
+ %value = mul <4 x i32> %lhs.shift, %rhs.shift
+ store <4 x i32> %value, ptr %out
+ %selected = shufflevector <4 x i32> %value, <4 x i32> poison, <2 x i32> <i32 0, i32 2>
+ %narrow = trunc <2 x i32> %selected to <2 x i8>
+ %result = sext <2 x i8> %narrow to <2 x i32>
+ ret <2 x i32> %result
+}
+
+define <2 x i32> @trunc_lanes01(<4 x i32> %lhs, ptr %out) {
+; CHECK-LABEL: trunc_lanes01:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI8_0
+; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI8_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: xtn v1.4h, v0.4s
+; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
+; CHECK-NEXT: str d1, [x0]
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 28, i32 24, i32 0, i32 0>
+ %value = trunc <4 x i32> %lhs.shift to <4 x i16>
+ store <4 x i16> %value, ptr %out
+ %selected = shufflevector <4 x i16> %value, <4 x i16> poison, <2 x i32> <i32 0, i32 1>
+ %narrow = trunc <2 x i16> %selected to <2 x i8>
+ %result = sext <2 x i8> %narrow to <2 x i32>
+ ret <2 x i32> %result
+}
+
+define <2 x i32> @trunc_lanes02(<4 x i32> %lhs, ptr %out) {
+; CHECK-LABEL: trunc_lanes02:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x8, .LCPI9_0
+; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI9_0]
+; CHECK-NEXT: sshl v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: xtn v1.4h, v0.4s
+; CHECK-NEXT: mov h0, v1.h[0]
+; CHECK-NEXT: str d1, [x0]
+; CHECK-NEXT: mov v0.h[2], v1.h[2]
+; CHECK-NEXT: shl v0.2s, v0.2s, #24
+; CHECK-NEXT: sshr v0.2s, v0.2s, #24
+; CHECK-NEXT: ret
+ %lhs.shift = ashr <4 x i32> %lhs, <i32 28, i32 24, i32 0, i32 0>
+ %value = trunc <4 x i32> %lhs.shift to <4 x i16>
+ store <4 x i16> %value, ptr %out
+ %selected = shufflevector <4 x i16> %value, <4 x i16> poison, <2 x i32> <i32 0, i32 2>
+ %narrow = trunc <2 x i16> %selected to <2 x i8>
+ %result = sext <2 x i8> %narrow to <2 x i32>
+ ret <2 x i32> %result
+}
+
diff --git a/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp b/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
index 50fd296ee747a..9d0f6e8a2b003 100644
--- a/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
+++ b/llvm/unittests/Target/AArch64/AArch64SelectionDAGTest.cpp
@@ -223,48 +223,6 @@ TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_VASHR) {
EXPECT_EQ(DAG->ComputeNumSignBits(Fr2), 5u);
}
-TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_MUL_DemandedElts) {
- SDLoc Loc;
- SDValue LHS = DAG->getRegister(1, MVT::v4i32);
- SDValue RHS = DAG->getRegister(2, MVT::v4i32);
- SDValue Zero = DAG->getConstant(0, Loc, MVT::i32);
- SDValue LHSShift =
- DAG->getBuildVector(MVT::v4i32, Loc,
- {DAG->getConstant(28, Loc, MVT::i32),
- DAG->getConstant(24, Loc, MVT::i32), Zero, Zero});
- SDValue RHSShift =
- DAG->getBuildVector(MVT::v4i32, Loc,
- {DAG->getConstant(26, Loc, MVT::i32),
- DAG->getConstant(22, Loc, MVT::i32), Zero, Zero});
- LHS = DAG->getNode(ISD::SRA, Loc, MVT::v4i32, LHS, LHSShift);
- RHS = DAG->getNode(ISD::SRA, Loc, MVT::v4i32, RHS, RHSShift);
- SDValue Mul = DAG->getNode(ISD::MUL, Loc, MVT::v4i32, LHS, RHS);
-
- EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0001)), 23u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0010)), 15u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0011)), 15u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Mul, APInt(4, 0b0100)), 1u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Mul), 1u);
-}
-
-TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_TRUNCATE_DemandedElts) {
- SDLoc Loc;
- SDValue Src = DAG->getRegister(1, MVT::v4i32);
- SDValue Zero = DAG->getConstant(0, Loc, MVT::i32);
- SDValue Shift =
- DAG->getBuildVector(MVT::v4i32, Loc,
- {DAG->getConstant(28, Loc, MVT::i32),
- DAG->getConstant(24, Loc, MVT::i32), Zero, Zero});
- Src = DAG->getNode(ISD::SRA, Loc, MVT::v4i32, Src, Shift);
- SDValue Trunc = DAG->getNode(ISD::TRUNCATE, Loc, MVT::v4i16, Src);
-
- EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0001)), 13u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0010)), 9u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0011)), 9u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Trunc, APInt(4, 0b0100)), 1u);
- EXPECT_EQ(DAG->ComputeNumSignBits(Trunc), 1u);
-}
-
TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_SUB) {
SDLoc Loc;
auto IntVT = EVT::getIntegerVT(Context, 8);
More information about the llvm-commits
mailing list