[llvm] [X86] Handle multi-use setcc in commuteSelect (PR #213645)

Timur Golubovich via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 12:56:22 PDT 2026


timurgol007 wrote:

@DKLoehr, thanks for reporting this. I managed to reduce it via `llvm-reduce` to the following reproducer:

llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 -mattr=+sse3 -O2 reduced.ll -o /dev/null

```ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define fastcc <8 x i32> @test(<8 x i32> %vecinit.i.i.i) #0 {
entry:
  %0 = icmp eq <8 x i32> %vecinit.i.i.i, <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
  %1 = icmp ne <8 x i32> %vecinit.i.i.i, <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
  %elt.min.i249.neg = sext <8 x i1> %1 to <8 x i32>
  %2 = select <8 x i1> %0, <8 x i32> zeroinitializer, <8 x i32> %elt.min.i249.neg
  %sub.i.i.i.i = sub <8 x i32> zeroinitializer, %2
  %3 = bitcast <8 x i32> %sub.i.i.i.i to <4 x i64>
  tail call void null(<4 x i64> zeroinitializer, <4 x i64> %3, ptr null, i32 0)
  %4 = select <8 x i1> %0, <8 x i32> zeroinitializer, <8 x i32> %vecinit.i.i.i
  %sub.i.i.i.i209 = sub <8 x i32> zeroinitializer, %4
  ret <8 x i32> %sub.i.i.i.i209
}

attributes #0 = { "target-features"="+avx10.1" }
```

This was already fixed by https://github.com/llvm/llvm-project/pull/214092. I had incorrectly assumed the CSE scenario couldn't happen in practice - clearly it can. Sorry for the breakage, and thanks again for the report.

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


More information about the llvm-commits mailing list