[llvm] [InstCombine] Select of Symmetric Selects (PR #99245)
Tim Gymnich via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 05:53:53 PDT 2024
tgymnich wrote:
Would be nice if we could also proof the splat case:
```llvm
define <2 x i4> @src(<2 x i4> %a, <2 x i4> %b, <2 x i1> %c1, i1 %c2) {
#0:
%sel1 = select <2 x i1> %c1, <2 x i4> %a, <2 x i4> %b
%sel2 = select <2 x i1> %c1, <2 x i4> %b, <2 x i4> %a
%ret = select i1 %c2, <2 x i4> %sel1, <2 x i4> %sel2
ret <2 x i4> %ret
}
=>
define <2 x i4> @tgt(<2 x i4> %a, <2 x i4> %b, <2 x i1> %c1, i1 %c2) {
#0:
%splat = insertelement <2 x i1> poison, i1 %c2, i32 0
%splat1 = insertelement <2 x i1> %splat, i1 %c2, i32 1
%xor = xor <2 x i1> %c1, %splat1
%ret = select <2 x i1> %xor, <2 x i4> %b, <2 x i4> %a
ret <2 x i4> %ret
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
<2 x i4> %a = < #x0 (0) [based on undef value], #x0 (0) [based on undef value] >
<2 x i4> %b = < poison, poison >
<2 x i1> %c1 = < #x0 (0), #x1 (1) >
i1 %c2 = undef
Source:
<2 x i4> %sel1 = < poison, #x0 (0) >
<2 x i4> %sel2 = < #x0 (0), poison >
<2 x i4> %ret = < poison, poison >
Target:
<2 x i1> %splat = < #x1 (1), poison >
<2 x i1> %splat1 = < #x1 (1), #x0 (0) >
<2 x i1> %xor = < #x1 (1), #x1 (1) >
<2 x i4> %ret = < poison, poison >
Source value: < poison, poison >
Target value: < poison, poison >
```
https://github.com/llvm/llvm-project/pull/99245
More information about the llvm-commits
mailing list