Skip to content
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

Change CMP with imm to large imm and vice versa to expose CSE opportunities with SUB #654

Open
vladimirradosavljevic opened this issue Jul 8, 2024 · 0 comments

Comments

@vladimirradosavljevic
Copy link
Contributor

#651 adds support for adjusting CMP instructions to expose CSE opportunities with SUB. That PR doesn't add support where adjusting CMP would require changing operand from immediate to constant pool and vice versa.
In the following tests, SUB instruction can be CSEd with CMP, but it's not:

define i256 @test_small_large_imm_ule(i256 %a, i1 %cond) {
  %add = add i256 %a, -65535
  %cmp = icmp ule i256 %a, 65535
  %select1 = select i1 %cmp, i256 %add, i256 %a
  %select2 = select i1 %cond, i256 %select1, i256 %add
  ret i256 %select2
}
define i256 @test_small_large_imm_uge(i256 %a, i1 %cond) {
  %add = add i256 %a, -65536
  %cmp = icmp uge i256 %a, 65536
  %select1 = select i1 %cmp, i256 %add, i256 %a
  %select2 = select i1 %cond, i256 %select1, i256 %add
  ret i256 %select2
}
@vladimirradosavljevic vladimirradosavljevic changed the title Change CMP with imm to large imm and vice versa to expose CSE opportunities Change CMP with imm to large imm and vice versa to expose CSE opportunities with SUB Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant