[llvm] [InstCombine] Fold select of and/or subset identity (PR #207925)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 7 01:59:49 PDT 2026
dtcxzyw wrote:
The following correctness issue was found by [llvm-hackme](https://github.com/dtcxzyw/llvm-hackme).
<!-- llvm-hackme-state: bug_found -->
<!-- llvm-hackme-baseline: adc3969513100367bd4b2cf6add8935cd308432b -->
<!-- llvm-hackme-head-sha: 574e84bf7fcec2c47708a8fa2141c5186a0aa32b -->
<!-- llvm-hackme-patch-sha256: 9c9d0f92a120bb24263b8b76a466f968cd4d8dee4832ec00efb38a788233de5c -->
<!-- llvm-hackme-kind: miscompilation -->
This comment is generated by an automated correctness checking service designed to help identify critical correctness bugs (opt crashes or Alive2 miscompilations) and improve PR review efficiency under limited reviewer bandwidth.
The reproducer was generated by LLM.
This bug is a regression introduced by this PR. It does not reproduce on the baseline commit.
## Reproducer
**Kind**: miscompilation
**IR Reproducer**:
```llvm
; RUN: opt -passes=instcombine<no-verify-fixpoint> -S
define i32 @f(i32 %a, i32 %b) {
%and = and i32 %a, %b
%cmp = icmp ne i32 %and, %b
%or = or disjoint i32 %a, %b
%sel = select i1 %cmp, i32 %or, i32 %a
ret i32 %sel
}
```
**Alive2 Counterexample**:
```
----------------------------------------
define i32 @f(i32 %a, i32 %b) {
#0:
%and = and i32 %a, %b
%cmp = icmp ne i32 %and, %b
%or = or disjoint i32 %a, %b
%sel = select i1 %cmp, i32 %or, i32 %a
ret i32 %sel
}
=>
define i32 @f(i32 %a, i32 %b) {
#0:
%or = or disjoint i32 %a, %b
ret i32 %or
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
i32 %a = #x0000000f (15)
i32 %b = #x0000000f (15)
Source:
i32 %and = #x0000000f (15)
i1 %cmp = #x0 (0)
i32 %or = poison
i32 %sel = #x0000000f (15)
Target:
i32 %or = poison
Source value: #x0000000f (15)
Target value: poison
Summary:
0 correct transformations
1 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
**Opt Output**:
```llvm
; ModuleID = '/tmp/tmp5_vu02pf.ll'
source_filename = "/tmp/tmp5_vu02pf.ll"
define i32 @f(i32 %a, i32 %b) {
%or = or disjoint i32 %a, %b
ret i32 %or
}
```
**Baseline Revision**: `adc3969513100367bd4b2cf6add8935cd308432b`
**PR Head SHA**: `574e84bf7fcec2c47708a8fa2141c5186a0aa32b`
**Patch SHA256**: `9c9d0f92a120bb24263b8b76a466f968cd4d8dee4832ec00efb38a788233de5c`
https://github.com/llvm/llvm-project/pull/207925
More information about the llvm-commits
mailing list