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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 06:38:45 PDT 2026


nikic wrote:

AI flagged that there is still a remaining issue here, even after https://github.com/llvm/llvm-project/pull/214092, specifically for the case where the same value is used twice:
```llvm
; -march=avx512bw
define <16 x i32> @f(<16 x i32> %a, <16 x i32> %b, <16 x i32> %c, <16 x i32> %d,
                     <16 x i1> %o1, <16 x i1> %o2, ptr %p) {
  %cc = icmp slt <16 x i32> %a, %b
  %o  = xor <16 x i1> %o1, %o2
  %r1 = select <16 x i1> %cc, <16 x i1> %cc, <16 x i1> %o
  %x  = add <16 x i32> %c, %d
  %r2 = select <16 x i1> %cc, <16 x i32> %a, <16 x i32> %x
  %m  = bitcast <16 x i1> %r1 to i16
  store i16 %m, ptr %p
  ret <16 x i32> %r2
}
```
In that case the user will be visited twice and the operands commuted twice.

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


More information about the llvm-commits mailing list