-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AArch64] computeKnownBitsForTargetNode - add AArch64ISD::MOVIshift support #148634
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
@llvm/pr-subscribers-backend-aarch64 Author: Simon Pilgrim (RKSimon) ChangesFixes #148596 Full diff: https://github.com/llvm/llvm-project/pull/148634.diff 5 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 55601e6327e98..bde4ba993f69e 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -2600,6 +2600,12 @@ void AArch64TargetLowering::computeKnownBitsForTargetNode(
APInt(Known.getBitWidth(), Op->getConstantOperandVal(0)));
break;
}
+ case AArch64ISD::MOVIshift: {
+ Known = KnownBits::makeConstant(
+ APInt(Known.getBitWidth(), Op->getConstantOperandVal(0)
+ << Op->getConstantOperandVal(1)));
+ break;
+ }
case AArch64ISD::LOADgot:
case AArch64ISD::ADDlow: {
if (!Subtarget->isTargetILP32())
@@ -30287,6 +30293,7 @@ bool AArch64TargetLowering::SimplifyDemandedBitsForTargetNode(
bool AArch64TargetLowering::isTargetCanonicalConstantNode(SDValue Op) const {
return Op.getOpcode() == AArch64ISD::DUP ||
Op.getOpcode() == AArch64ISD::MOVI ||
+ Op.getOpcode() == AArch64ISD::MOVIshift ||
(Op.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
Op.getOperand(0).getOpcode() == AArch64ISD::DUP) ||
TargetLowering::isTargetCanonicalConstantNode(Op);
diff --git a/llvm/test/CodeGen/AArch64/arm64-zip.ll b/llvm/test/CodeGen/AArch64/arm64-zip.ll
index 20d0c7f1b7085..9b06620590cda 100644
--- a/llvm/test/CodeGen/AArch64/arm64-zip.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-zip.ll
@@ -454,7 +454,7 @@ define <4 x i32> @shuffle_zip3(<4 x i32> %arg) {
; CHECK-NEXT: zip2.4h v0, v0, v1
; CHECK-NEXT: movi.4s v1, #1
; CHECK-NEXT: zip1.4h v0, v0, v0
-; CHECK-NEXT: sshll.4s v0, v0, #0
+; CHECK-NEXT: ushll.4s v0, v0, #0
; CHECK-NEXT: and.16b v0, v0, v1
; CHECK-NEXT: ret
bb:
diff --git a/llvm/test/CodeGen/AArch64/combine-mul.ll b/llvm/test/CodeGen/AArch64/combine-mul.ll
index c49e5ae6620a9..ff6d1a571a084 100644
--- a/llvm/test/CodeGen/AArch64/combine-mul.ll
+++ b/llvm/test/CodeGen/AArch64/combine-mul.ll
@@ -28,10 +28,7 @@ define <4 x i1> @PR48683_vec(<4 x i32> %x) {
define <4 x i1> @PR48683_vec_undef(<4 x i32> %x) {
; CHECK-LABEL: PR48683_vec_undef:
; CHECK: // %bb.0:
-; CHECK-NEXT: movi v1.4s, #2
-; CHECK-NEXT: mul v0.4s, v0.4s, v0.4s
-; CHECK-NEXT: cmtst v0.4s, v0.4s, v1.4s
-; CHECK-NEXT: xtn v0.4h, v0.4s
+; CHECK-NEXT: movi v0.2d, #0000000000000000
; CHECK-NEXT: ret
%a = mul <4 x i32> %x, %x
%b = and <4 x i32> %a, <i32 2, i32 2, i32 2, i32 undef>
diff --git a/llvm/test/CodeGen/AArch64/fast-isel-cmp-vec.ll b/llvm/test/CodeGen/AArch64/fast-isel-cmp-vec.ll
index ee2d940b8573a..11f36508c42d0 100644
--- a/llvm/test/CodeGen/AArch64/fast-isel-cmp-vec.ll
+++ b/llvm/test/CodeGen/AArch64/fast-isel-cmp-vec.ll
@@ -26,7 +26,6 @@ define <2 x i32> @icmp_constfold_v2i32(<2 x i32> %a) {
; CHECK-LABEL: icmp_constfold_v2i32:
; CHECK: ; %bb.0:
; CHECK-NEXT: movi.2s v0, #1
-; CHECK-NEXT: and.8b v0, v0, v0
; CHECK-NEXT: ret
%1 = icmp eq <2 x i32> %a, %a
br label %bb2
@@ -56,8 +55,6 @@ define <4 x i32> @icmp_constfold_v4i32(<4 x i32> %a) {
; CHECK-LABEL: icmp_constfold_v4i32:
; CHECK: ; %bb.0:
; CHECK-NEXT: movi.4h v0, #1
-; CHECK-NEXT: ; %bb.1: ; %bb2
-; CHECK-NEXT: and.8b v0, v0, v0
; CHECK-NEXT: ushll.4s v0, v0, #0
; CHECK-NEXT: ret
%1 = icmp eq <4 x i32> %a, %a
diff --git a/llvm/test/CodeGen/AArch64/zext-to-tbl.ll b/llvm/test/CodeGen/AArch64/zext-to-tbl.ll
index 2a37183c47d51..74a717f1635a3 100644
--- a/llvm/test/CodeGen/AArch64/zext-to-tbl.ll
+++ b/llvm/test/CodeGen/AArch64/zext-to-tbl.ll
@@ -1246,33 +1246,33 @@ define void @zext_v16i4_to_v16i32_in_loop(ptr %src, ptr %dst) {
; CHECK-NEXT: add x8, x8, #16
; CHECK-NEXT: cmp x8, #128
; CHECK-NEXT: ubfx x12, x9, #48, #4
-; CHECK-NEXT: ubfx x10, x9, #52, #4
-; CHECK-NEXT: ubfx x14, x9, #32, #4
+; CHECK-NEXT: lsr x10, x9, #52
+; CHECK-NEXT: ubfx x13, x9, #32, #4
; CHECK-NEXT: ubfx w15, w9, #16, #4
-; CHECK-NEXT: ubfx x11, x9, #36, #4
-; CHECK-NEXT: ubfx w13, w9, #20, #4
+; CHECK-NEXT: lsr x11, x9, #36
+; CHECK-NEXT: lsr w14, w9, #20
; CHECK-NEXT: fmov s1, w12
-; CHECK-NEXT: fmov s2, w14
-; CHECK-NEXT: ubfx w12, w9, #4, #4
+; CHECK-NEXT: fmov s2, w13
+; CHECK-NEXT: lsr w12, w9, #4
; CHECK-NEXT: fmov s3, w15
; CHECK-NEXT: mov.h v1[1], w10
; CHECK-NEXT: and w10, w9, #0xf
; CHECK-NEXT: mov.h v2[1], w11
; CHECK-NEXT: fmov s4, w10
-; CHECK-NEXT: ubfx x11, x9, #56, #4
-; CHECK-NEXT: mov.h v3[1], w13
-; CHECK-NEXT: ubfx x10, x9, #40, #4
+; CHECK-NEXT: lsr x11, x9, #56
+; CHECK-NEXT: mov.h v3[1], w14
+; CHECK-NEXT: lsr x10, x9, #40
; CHECK-NEXT: mov.h v4[1], w12
-; CHECK-NEXT: ubfx w12, w9, #24, #4
+; CHECK-NEXT: lsr w12, w9, #24
; CHECK-NEXT: mov.h v1[2], w11
-; CHECK-NEXT: ubfx w11, w9, #8, #4
+; CHECK-NEXT: lsr w11, w9, #8
; CHECK-NEXT: mov.h v2[2], w10
; CHECK-NEXT: lsr x10, x9, #60
; CHECK-NEXT: mov.h v3[2], w12
-; CHECK-NEXT: ubfx x12, x9, #44, #4
+; CHECK-NEXT: lsr x12, x9, #44
; CHECK-NEXT: mov.h v4[2], w11
; CHECK-NEXT: lsr w11, w9, #28
-; CHECK-NEXT: ubfx w9, w9, #12, #4
+; CHECK-NEXT: lsr w9, w9, #12
; CHECK-NEXT: mov.h v1[3], w10
; CHECK-NEXT: mov.h v2[3], w12
; CHECK-NEXT: mov.h v3[3], w11
@@ -1300,38 +1300,37 @@ define void @zext_v16i4_to_v16i32_in_loop(ptr %src, ptr %dst) {
; CHECK-BE-NEXT: ldr x9, [x0, x8]
; CHECK-BE-NEXT: add x8, x8, #16
; CHECK-BE-NEXT: cmp x8, #128
-; CHECK-BE-NEXT: ubfx w12, w9, #12, #4
+; CHECK-BE-NEXT: ubfx w11, w9, #12, #4
; CHECK-BE-NEXT: lsr w14, w9, #28
-; CHECK-BE-NEXT: ubfx w10, w9, #8, #4
+; CHECK-BE-NEXT: lsr w10, w9, #8
; CHECK-BE-NEXT: ubfx x15, x9, #44, #4
-; CHECK-BE-NEXT: ubfx w11, w9, #24, #4
-; CHECK-BE-NEXT: ubfx x13, x9, #40, #4
-; CHECK-BE-NEXT: fmov s1, w12
-; CHECK-BE-NEXT: lsr x12, x9, #60
+; CHECK-BE-NEXT: lsr w12, w9, #24
+; CHECK-BE-NEXT: lsr x13, x9, #40
+; CHECK-BE-NEXT: fmov s1, w11
+; CHECK-BE-NEXT: lsr x11, x9, #60
; CHECK-BE-NEXT: fmov s2, w14
; CHECK-BE-NEXT: fmov s3, w15
-; CHECK-BE-NEXT: fmov s4, w12
-; CHECK-BE-NEXT: ubfx w12, w9, #20, #4
+; CHECK-BE-NEXT: fmov s4, w11
+; CHECK-BE-NEXT: lsr w11, w9, #20
; CHECK-BE-NEXT: mov v1.h[1], w10
-; CHECK-BE-NEXT: ubfx x10, x9, #56, #4
-; CHECK-BE-NEXT: mov v2.h[1], w11
-; CHECK-BE-NEXT: ubfx w11, w9, #4, #4
+; CHECK-BE-NEXT: lsr x10, x9, #56
+; CHECK-BE-NEXT: mov v2.h[1], w12
+; CHECK-BE-NEXT: lsr w12, w9, #4
; CHECK-BE-NEXT: mov v3.h[1], w13
; CHECK-BE-NEXT: mov v4.h[1], w10
-; CHECK-BE-NEXT: ubfx x10, x9, #36, #4
-; CHECK-BE-NEXT: mov v1.h[2], w11
-; CHECK-BE-NEXT: ubfx x11, x9, #52, #4
-; CHECK-BE-NEXT: mov v2.h[2], w12
+; CHECK-BE-NEXT: lsr x10, x9, #36
+; CHECK-BE-NEXT: mov v1.h[2], w12
+; CHECK-BE-NEXT: lsr x12, x9, #52
+; CHECK-BE-NEXT: mov v2.h[2], w11
; CHECK-BE-NEXT: mov v3.h[2], w10
-; CHECK-BE-NEXT: and w10, w9, #0xf
-; CHECK-BE-NEXT: ubfx w12, w9, #16, #4
-; CHECK-BE-NEXT: mov v4.h[2], w11
-; CHECK-BE-NEXT: ubfx x11, x9, #32, #4
-; CHECK-BE-NEXT: ubfx x9, x9, #48, #4
-; CHECK-BE-NEXT: mov v1.h[3], w10
-; CHECK-BE-NEXT: mov v2.h[3], w12
-; CHECK-BE-NEXT: add x10, x1, #32
+; CHECK-BE-NEXT: lsr w10, w9, #16
+; CHECK-BE-NEXT: lsr x11, x9, #32
+; CHECK-BE-NEXT: mov v4.h[2], w12
+; CHECK-BE-NEXT: mov v1.h[3], w9
+; CHECK-BE-NEXT: lsr x9, x9, #48
+; CHECK-BE-NEXT: mov v2.h[3], w10
; CHECK-BE-NEXT: mov v3.h[3], w11
+; CHECK-BE-NEXT: add x10, x1, #32
; CHECK-BE-NEXT: mov v4.h[3], w9
; CHECK-BE-NEXT: add x9, x1, #48
; CHECK-BE-NEXT: ushll v1.4s, v1.4h, #0
|
davemgreen
approved these changes
Jul 14, 2025
Collaborator
davemgreen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, thanks. LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #148596