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] noundef attribute should be dropped after setting is_zero_poison to true #112068

Open
dtcxzyw opened this issue Oct 12, 2024 · 0 comments

Comments

@dtcxzyw
Copy link
Member

dtcxzyw commented Oct 12, 2024

Reproducer: https://alive2.llvm.org/ce/z/7-TgAf

define i32 @src(i32 %x, i32 %y) {
entry:
  %cttz = call noundef i32 @llvm.cttz.i32(i32 %y, i1 false)
  %res = lshr i32 %x, %cttz
  ret i32 %res
}

define i32 @tgt(i32 %x, i32 %y) {
entry:
  %cttz = call noundef i32 @llvm.cttz.i32(i32 %y, i1 true)
  %res = lshr i32 %x, %cttz
  ret i32 %res
}

define i32 @src2(i32 %x) {
  %ct = call noundef i32 @llvm.ctlz.i32(i32 %x, i1 false)
  %cmp = icmp ne i32 %x, 0
  %res = select i1 %cmp, i32 %ct, i32 123
  ret i32 %res
}

define i32 @tgt2(i32 %x) {
  %ct = call noundef i32 @llvm.ctlz.i32(i32 %x, i1 true)
  %cmp = icmp ne i32 %x, 0
  %res = select i1 %cmp, i32 %ct, i32 123
  ret i32 %res
}

noundef attribute should be dropped. Otherwise we will convert a poison value to immediate UB.

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

1 participant