-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[SelectionDAG] Fold (icmp eq/ne (shift X, C), 0) -> (icmp eq/ne X, 0) #88801
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -586,6 +586,7 @@ define i1 @add_ultcmp_i32_i16(i32 %x) nounwind { | |
; RV64I-NEXT: lui a1, 8 | ||
; RV64I-NEXT: add a0, a0, a1 | ||
; RV64I-NEXT: srliw a0, a0, 16 | ||
; RV64I-NEXT: slli a0, a0, 16 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like RISCV isn't optimizing
as good as
It does fold SRL+AND into a single srliw. But the AND is lowered into srliw+slli. Problem is that it would need to understand that the using setcc doesn't care about where the bits go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldFoldConstantShiftPairToMask is enabled by default - is that affecting it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think shouldFoldConstantShiftPairToMask has anything to do with it here, since I can't see any shift pair being created in the first place. We could add a new hook to avoid the simplification done here for RISCV. But I really think that this is something that RISCV should handle at selection (i.e. allowing the simplified DAG, but doing a better selection). |
||
; RV64I-NEXT: seqz a0, a0 | ||
; RV64I-NEXT: ret | ||
; | ||
|
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.
Skip doing anything if the flags are already set?
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.
I've tried to guard the most expensive computations below by checking if the flags already are present. So not quite sure what you propose.