[llvm] [InstCombine] Teach foldSelectOpOp about samesign (PR #122723)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 13:47:08 PST 2025


nikic wrote:

Single-function reproducer for `-passes=instcombine` (https://alive2.llvm.org/ce/z/dMgLMj):

```llvm
define i1 @test(i32 %3) {
entry:
  %4 = icmp slt i32 %3, 0
  %.not.i.i = xor i1 true, %4
  %5 = icmp samesign ult i32 %3, 131072
  %spec.select = select i1 %.not.i.i, i1 %5, i1 %4
  %6 = xor i1 %spec.select, true
  %7 = icmp samesign ult i32 %3, -1
  %or.cond = select i1 %4, i1 %7, i1 false
  %or.cond2 = select i1 %6, i1 true, i1 %or.cond
  ret i1 %or.cond2
}
```

https://github.com/llvm/llvm-project/pull/122723


More information about the llvm-commits mailing list