-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[RISCV] Added ROLW/RORW/SLLW/SRAW/SRLW for canCreateUndefOrPoisonForTargetNode #152609
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
@llvm/pr-subscribers-backend-risc-v Author: Jasmine Tang (badumbatish) ChangesFixes #149285. Full diff: https://github.com/llvm/llvm-project/pull/152609.diff 1 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index adbfbeb4669e7..d86ec003459d3 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -21477,6 +21477,14 @@ bool RISCVTargetLowering::canCreateUndefOrPoisonForTargetNode(
// TODO: Add more target nodes.
switch (Op.getOpcode()) {
+ case RISCVISD::SLLW:
+ case RISCVISD::SRAW:
+ case RISCVISD::SRLW:
+ case RISCVISD::RORW:
+ case RISCVISD::ROLW:
+ // Only the lower 5 bits of RHS are read, guaranteeing the rotate/shift
+ // amount is bounds.
+ return false;
case RISCVISD::SELECT_CC:
// Integer select_cc cannot create poison.
// TODO: What are the FP poison semantics?
|
The only place where I see this piece of code used is via visitFreeze in But in visiting freeze (hoping to hit sllw), freeze is still wrapping sext and shl, not sllw yet. Therefore I'm not sure if there's any other tests to be constructed. I'm also not sure what kind of visible effects can I test for here? i.e even if freeze unwraps itself for a sllw inside, how does that change the assembly? Putting it as draft for now Test case is define i64 @shl(i32 %x, i32 %y) {
; CHECK64I-LABEL: shl:
; CHECK64I: # %bb.0:
; CHECK64I-NEXT: sllw a0, a0, a1
; CHECK64I-NEXT: ret
%m = and i32 %y, 31
%s = shl i32 %x, %m
%r = sext i32 %s to i64
%hhhh = freeze i64 %r
ret i64 %r
} |
Co-authored-by: RKSimon <RKSimon@users.noreply.github.com>
0dc3ad6
to
efa71ac
Compare
@topperc Do you have any objections to this going in without tests? |
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
No objection. Writing a test is probably tricky since this node appears after type legalization. So the freeze would also need to be created after type legalization to avoid it getting optimized earlier. |
Fixes #149285.