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] range attribute should be dropped in foldIsPowerOf2OrZero #112078

Closed
dtcxzyw opened this issue Oct 12, 2024 · 0 comments · Fixed by #112178
Closed

[InstCombine] range attribute should be dropped in foldIsPowerOf2OrZero #112078

dtcxzyw opened this issue Oct 12, 2024 · 0 comments · Fixed by #112178

Comments

@dtcxzyw
Copy link
Member

dtcxzyw commented Oct 12, 2024

Reproducer: https://alive2.llvm.org/ce/z/u62KKP (Please use latest alive2 with AliveToolkit/alive2#1097)

define i1 @src(i32 %x) {
  %t0 = tail call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)
  %cmp = icmp ne i32 %t0, 1
  %notzero = icmp ne i32 %x, 0
  %r = select i1 %notzero, i1 %cmp, i1 false
  ret i1 %r
}

define i1 @tgt(i32 %x) {
  %t0 = tail call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %x)
  %r = icmp ugt i32 %t0, 1
  ret i1 %r
}
----------------------------------------
define i1 @src(i32 %x) {
#0:
  %t0 = ctpop i32 %x
  %#range_0_%t0 = !range i32 %t0, i32 1, i32 33
  %cmp = icmp ne i32 %#range_0_%t0, 1
  %notzero = icmp ne i32 %x, 0
  %r = select i1 %notzero, i1 %cmp, i1 0
  ret i1 %r
}
=>
define i1 @tgt(i32 %x) {
#0:
  %t0 = ctpop i32 %x
  %#range_0_%t0 = !range i32 %t0, i32 1, i32 33
  %r = icmp ugt i32 %#range_0_%t0, 1
  ret i1 %r
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
i32 %x = #x00000000 (0)

Source:
i32 %t0 = #x00000000 (0)
i32 %#range_0_%t0 = poison
i1 %cmp = poison
i1 %notzero = #x0 (0)
i1 %r = #x0 (0)

Target:
i32 %t0 = #x00000000 (0)
i32 %#range_0_%t0 = poison
i1 %r = poison
Source value: #x0 (0)
Target value: poison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant