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

[GlobalISel] Add computeNumSignBits for G_BUILD_VECTOR. #139506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[GlobalISel] Add computeNumSignBits for G_BUILD_VECTOR.
  • Loading branch information
davemgreen committed May 13, 2025
commit ef102114ae74a8ff8fe04e5c0bb7502fe6deff13
18 changes: 18 additions & 0 deletions 18 llvm/lib/CodeGen/GlobalISel/GISelValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,24 @@ unsigned GISelValueTracking::computeNumSignBits(Register R,
return TyBits - 1; // Every always-zero bit is a sign bit.
break;
}
case TargetOpcode::G_BUILD_VECTOR: {
// Collect the known bits that are shared by every demanded vector element.
FirstAnswer = TyBits;
APInt SingleDemandedElt(1, 1);
for (unsigned i = 0, e = MI.getNumOperands() - 1; i < e; ++i) {
if (!DemandedElts[i])
continue;

unsigned Tmp2 = computeNumSignBits(MI.getOperand(i + 1).getReg(),
SingleDemandedElt, Depth + 1);
FirstAnswer = std::min(FirstAnswer, Tmp2);

// If we don't know any bits, early out.
if (FirstAnswer == 1)
break;
}
break;
}
case TargetOpcode::G_INTRINSIC:
case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
case TargetOpcode::G_INTRINSIC_CONVERGENT:
Expand Down
13 changes: 6 additions & 7 deletions 13 llvm/test/CodeGen/AArch64/aarch64-dup-ext.ll
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,14 @@ define <4 x i32> @nonsplat_shuffleinsert2(<4 x i16> %b, i16 %b0, i16 %b1, i16 %b
; CHECK-GI-LABEL: nonsplat_shuffleinsert2:
; CHECK-GI: // %bb.0: // %entry
; CHECK-GI-NEXT: sxth w8, w0
; CHECK-GI-NEXT: sshll v0.4s, v0.4h, #0
; CHECK-GI-NEXT: mov v1.s[0], w8
; CHECK-GI-NEXT: sxth w8, w1
; CHECK-GI-NEXT: mov v1.s[1], w8
; CHECK-GI-NEXT: sxth w9, w1
; CHECK-GI-NEXT: fmov s1, w8
; CHECK-GI-NEXT: sxth w8, w2
; CHECK-GI-NEXT: mov v1.s[2], w8
; CHECK-GI-NEXT: mov v1.h[1], w9
; CHECK-GI-NEXT: mov v1.h[2], w8
; CHECK-GI-NEXT: sxth w8, w3
; CHECK-GI-NEXT: mov v1.s[3], w8
; CHECK-GI-NEXT: mul v0.4s, v1.4s, v0.4s
; CHECK-GI-NEXT: mov v1.h[3], w8
; CHECK-GI-NEXT: smull v0.4s, v1.4h, v0.4h
; CHECK-GI-NEXT: ret
entry:
%s0 = sext i16 %b0 to i32
Expand Down
2 changes: 1 addition & 1 deletion 2 llvm/unittests/CodeGen/GlobalISel/KnownBitsVectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ TEST_F(AArch64GISelMITest, TestVectorNumSignBitsConstant) {
EXPECT_EQ(2u, Info.computeNumSignBits(CopyReg32));
EXPECT_EQ(3u, Info.computeNumSignBits(CopyRegNeg32));
EXPECT_EQ(3u, Info.computeNumSignBits(NonSplatSameSign));
EXPECT_EQ(1u, Info.computeNumSignBits(NonSplatDifferentSign));
EXPECT_EQ(2u, Info.computeNumSignBits(NonSplatDifferentSign));
}

TEST_F(AArch64GISelMITest, TestVectorNumSignBitsSext) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.