Skip to content

[AArch64] Return early rather than asserting when Size of value passed to targetShrinkDemandedConstant is not 32 or 64 #123084

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
Jan 17, 2025

Conversation

WillFroom
Copy link
Contributor

See #123029 for details.

@llvmbot
Copy link
Member

llvmbot commented Jan 15, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Will Froom (WillFroom)

Changes

See #123029 for details.


Full diff: https://github.com/llvm/llvm-project/pull/123084.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+5-2)
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index d4a114c275fb76..32abcfe7a8f452 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -2373,8 +2373,11 @@ bool AArch64TargetLowering::targetShrinkDemandedConstant(
     return false;
 
   unsigned Size = VT.getSizeInBits();
-  assert((Size == 32 || Size == 64) &&
-         "i32 or i64 is expected after legalization.");
+
+  if((Size != 32 || Size != 64))
+  {
+    return false;
+  }
 
   // Exit early if we demand all bits.
   if (DemandedBits.popcount() == Size)

Copy link

github-actions bot commented Jan 15, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@WillFroom WillFroom force-pushed the fix-arm-constant-shrink branch 3 times, most recently from 53f9b3c to bfdd622 Compare January 15, 2025 17:07
@davemgreen
Copy link
Collaborator

Thanks for doing this, it sounds like the right place to change to me. Could you add the test case from #123029?

@davemgreen davemgreen self-requested a review January 15, 2025 18:13
@WillFroom WillFroom force-pushed the fix-arm-constant-shrink branch from bfdd622 to 2a29570 Compare January 16, 2025 12:33
@WillFroom
Copy link
Contributor Author

@davemgreen I've added a test that does no more than simply run the compilation pipeline with no explicit checks, let me know if you are happy with that (I have confirmed that it fails prior to my change)

@WillFroom WillFroom force-pushed the fix-arm-constant-shrink branch from 2a29570 to 8df0cc3 Compare January 16, 2025 15:57
Copy link
Collaborator

@davemgreen davemgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have some nitpicks over cleaning up the test a little, but otherwise LGTM.

…d to targetShrinkDemandedConstant is not 32 or 64
@WillFroom WillFroom force-pushed the fix-arm-constant-shrink branch from 8df0cc3 to 6d0cdae Compare January 16, 2025 19:54
@WillFroom
Copy link
Contributor Author

@davemgreen thanks for the review, I am waiting on commit access (#122733) so if you are happy could you press merge, cheers.

@davemgreen davemgreen merged commit c8ba551 into llvm:main Jan 17, 2025
8 checks passed
@davemgreen
Copy link
Collaborator

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants