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

[InstCombine] fold signbit test of a pow2-or-zero #60957

Closed
rotateright opened this issue Feb 23, 2023 · 2 comments
Closed

[InstCombine] fold signbit test of a pow2-or-zero #60957

rotateright opened this issue Feb 23, 2023 · 2 comments
Assignees

Comments

@rotateright
Copy link
Contributor

This probably isn't worth the compile-time cost of using ValueTracking, but we could add a direct pattern match for this and similar icmp patterns:

define i1 @src(i8 %x) {
  %negx = sub i8 0, %x
  %pow2_or_zero = and i8 %negx, %x 
  %cmp = icmp slt i8 %pow2_or_zero, 0
  ret i1 %cmp
}

define i1 @tgt(i8 %x) {
  %cmp = icmp eq i8 %x, -128
  ret i1 %cmp
}

https://alive2.llvm.org/ce/z/_J5q3S

@junaire
Copy link
Member

junaire commented Feb 25, 2023

I would like to have a try :)

@junaire junaire self-assigned this Feb 25, 2023
@junaire
Copy link
Member

junaire commented Feb 25, 2023

Candidate patch: https://reviews.llvm.org/D144777

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

No branches or pull requests

3 participants