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] poison-generating attributes are not dropped when folding logical and/or of icmps #111934

Closed
dtcxzyw opened this issue Oct 11, 2024 · 0 comments · Fixed by #111946
Closed

Comments

@dtcxzyw
Copy link
Member

dtcxzyw commented Oct 11, 2024

Reproducer: https://alive2.llvm.org/ce/z/rSUfvo

define i1 @src(i32 noundef %Value) {
entry:
  %cmp.not = icmp eq i32 %Value, 0
  %0 = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %Value)
  %cmp1 = icmp ult i32 %0, 2
  %1 = select i1 %cmp.not, i1 false, i1 %cmp1
  ret i1 %1
}

define i1 @tgt(i32 noundef %Value) {
entry:
  %0 = call range(i32 1, 33) i32 @llvm.ctpop.i32(i32 %Value)
  %1 = icmp eq i32 %0, 1
  ret i1 %1
}

When %Value == 0, @src returns false but @tgt returns poison.
This miscompilation was triggered after #111284 was landed.

@dtcxzyw dtcxzyw self-assigned this Oct 11, 2024
@dtcxzyw dtcxzyw changed the title [InstCombine] poison-generating attributes are not dropped when threading icmps over selects [InstCombine] poison-generating attributes are not dropped when folding logical and/or of icmps Oct 11, 2024
dtcxzyw added a commit to dtcxzyw/llvm-project that referenced this issue Oct 11, 2024
tru pushed a commit to dtcxzyw/llvm-project that referenced this issue Oct 15, 2024
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this issue Oct 16, 2024
bricknerb pushed a commit to bricknerb/llvm-project that referenced this issue Oct 17, 2024
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