Skip to content

[InstCombine] fold bit-hack form of signbit test #57394

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

Closed
rotateright opened this issue Aug 26, 2022 · 1 comment
Closed

[InstCombine] fold bit-hack form of signbit test #57394

rotateright opened this issue Aug 26, 2022 · 1 comment

Comments

@rotateright
Copy link
Contributor

rotateright commented Aug 26, 2022

Missed fold in IR noticed while trying to fix #57381:

define i32 @src(i16 %x) {
  %a = ashr i16 %x, 15 ; -1 if negative, 0 if not-negative
  %r = add i16 %a, 1   ; 0 if negative, 1 if not-negative
  %r2 = zext i16 %r to i32
  ret i32 %r2
}

define i32 @tgt(i16 %x) {
  %a = icmp sgt i16 %x, -1
  %r2 = zext i1 %a to i32
  ret i32 %r2
}

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

@rotateright
Copy link
Contributor Author

We miss the more basic fold without the cast:
https://alive2.llvm.org/ce/z/5CrWQR

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

2 participants