-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[RISCV] Pass sign-extended value to isInt check in expandMul #150211
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
Conversation
In the isInt check that was added in # we were passing the zero-extended uint64_t value instead of the sign-extended one.
@llvm/pr-subscribers-backend-risc-v Author: Sudharsan Veeravalli (svs-quic) ChangesIn the Full diff: https://github.com/llvm/llvm-project/pull/150211.diff 1 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 3918dd21bc09d..fa0196ff25339 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -16079,7 +16079,7 @@ static SDValue expandMul(SDNode *N, SelectionDAG &DAG,
uint64_t MulAmt = CNode->getZExtValue();
// Don't do this if the Xqciac extension is enabled and the MulAmt in simm12.
- if (Subtarget.hasVendorXqciac() && isInt<12>(MulAmt))
+ if (Subtarget.hasVendorXqciac() && isInt<12>(CNode->getSExtValue()))
return SDValue();
const bool HasShlAdd = Subtarget.hasStdExtZba() ||
|
Is it possible to test? |
Have added a test now. |
Spotted while reviewing llvm#150211. If we're multiplying by -3 in i32 MulAmt contains 4,294,967,293 since we zero extend to uint64_t. Adding 3 to this gives 0x100000000 which is a power of 2 and the log2 of that is 32, but we can't shift left by 32 in an i32. We should use 0 instead of the shl in this case. Normally we don't hit this case because decomeMulByConstant handles it, but that's disabled by Qciac. And after llvm#150211 the path in expandMul will also be unreachable. So I didn't add a test to avoid messing with that review.
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.
LGTM
I think we should backport this to the release branch. |
/cherry-pick d3937e2 |
/pull-request #150556 |
Spotted while reviewing #150211. If we're multiplying by -3 in i32 MulAmt contains 4,294,967,293 since we zero extend to uint64_t. Adding 3 to this gives 0x100000000 which is a power of 2 and the log2 of that is 32, but we can't shift left by 32 in an i32. Detect this case and skip the transform. We could use 0, but we don't handle the case for i64 so this seemed more consistent. Normally we don't hit this case because decomposeMulByConstant handles it, but that's disabled by Xqciac. And after #150211 the code in expandMul is now unreachable for this case.
In the
isInt
check that was added in #147661 we were passing the zero-extendeduint64_t
value instead of the sign-extended one.