Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 137aa57

Browse filesBrowse files
authored
[GlobalISel] Add computeNumSignBits for G_BUILD_VECTOR. (#139506)
The code is similar to SelectionDAG::ComputeNumSignBits, but does not deal with truncating buildvectors.
1 parent cdbc297 commit 137aa57
Copy full SHA for 137aa57

File tree

Expand file treeCollapse file tree

3 files changed

+25
-8
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-8
lines changed

‎llvm/lib/CodeGen/GlobalISel/GISelValueTracking.cpp

Copy file name to clipboardExpand all lines: llvm/lib/CodeGen/GlobalISel/GISelValueTracking.cpp
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,24 @@ unsigned GISelValueTracking::computeNumSignBits(Register R,
836836
return TyBits - 1; // Every always-zero bit is a sign bit.
837837
break;
838838
}
839+
case TargetOpcode::G_BUILD_VECTOR: {
840+
// Collect the known bits that are shared by every demanded vector element.
841+
FirstAnswer = TyBits;
842+
APInt SingleDemandedElt(1, 1);
843+
for (unsigned i = 0, e = MI.getNumOperands() - 1; i < e; ++i) {
844+
if (!DemandedElts[i])
845+
continue;
846+
847+
unsigned Tmp2 = computeNumSignBits(MI.getOperand(i + 1).getReg(),
848+
SingleDemandedElt, Depth + 1);
849+
FirstAnswer = std::min(FirstAnswer, Tmp2);
850+
851+
// If we don't know any bits, early out.
852+
if (FirstAnswer == 1)
853+
break;
854+
}
855+
break;
856+
}
839857
case TargetOpcode::G_INTRINSIC:
840858
case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
841859
case TargetOpcode::G_INTRINSIC_CONVERGENT:

‎llvm/test/CodeGen/AArch64/aarch64-dup-ext.ll

Copy file name to clipboardExpand all lines: llvm/test/CodeGen/AArch64/aarch64-dup-ext.ll
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,14 @@ define <4 x i32> @nonsplat_shuffleinsert2(<4 x i16> %b, i16 %b0, i16 %b1, i16 %b
312312
; CHECK-GI-LABEL: nonsplat_shuffleinsert2:
313313
; CHECK-GI: // %bb.0: // %entry
314314
; CHECK-GI-NEXT: sxth w8, w0
315-
; CHECK-GI-NEXT: sshll v0.4s, v0.4h, #0
316-
; CHECK-GI-NEXT: mov v1.s[0], w8
317-
; CHECK-GI-NEXT: sxth w8, w1
318-
; CHECK-GI-NEXT: mov v1.s[1], w8
315+
; CHECK-GI-NEXT: sxth w9, w1
316+
; CHECK-GI-NEXT: fmov s1, w8
319317
; CHECK-GI-NEXT: sxth w8, w2
320-
; CHECK-GI-NEXT: mov v1.s[2], w8
318+
; CHECK-GI-NEXT: mov v1.h[1], w9
319+
; CHECK-GI-NEXT: mov v1.h[2], w8
321320
; CHECK-GI-NEXT: sxth w8, w3
322-
; CHECK-GI-NEXT: mov v1.s[3], w8
323-
; CHECK-GI-NEXT: mul v0.4s, v1.4s, v0.4s
321+
; CHECK-GI-NEXT: mov v1.h[3], w8
322+
; CHECK-GI-NEXT: smull v0.4s, v1.4h, v0.4h
324323
; CHECK-GI-NEXT: ret
325324
entry:
326325
%s0 = sext i16 %b0 to i32

‎llvm/unittests/CodeGen/GlobalISel/KnownBitsVectorTest.cpp

Copy file name to clipboardExpand all lines: llvm/unittests/CodeGen/GlobalISel/KnownBitsVectorTest.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ TEST_F(AArch64GISelMITest, TestVectorNumSignBitsConstant) {
692692
EXPECT_EQ(2u, Info.computeNumSignBits(CopyReg32));
693693
EXPECT_EQ(3u, Info.computeNumSignBits(CopyRegNeg32));
694694
EXPECT_EQ(3u, Info.computeNumSignBits(NonSplatSameSign));
695-
EXPECT_EQ(1u, Info.computeNumSignBits(NonSplatDifferentSign));
695+
EXPECT_EQ(2u, Info.computeNumSignBits(NonSplatDifferentSign));
696696
}
697697

698698
TEST_F(AArch64GISelMITest, TestVectorNumSignBitsSext) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.