<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113867>113867</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Can't splat undefined conditions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bongjunj
</td>
</tr>
</table>
<pre>
https://github.com/llvm/llvm-project/blob/5d4a0d54b5269bad1410e6db957836fe98634069/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L2288-L2304
Alive2 report: https://alive2.llvm.org/ce/z/k4KWVu
```llvm
----------------------------------------
define <4 x i32> @extract_cond_type_mismatch.2(<4 x i32> %x, <5 x i1> %condv) {
#0:
%cond = extractelement <5 x i1> %condv, i32 1
%#1 = add i1 %cond, 0
%r = select i1 %#1, <4 x i32> %x, <4 x i32> { 0, 0, 0, 0 }
ret <4 x i32> %r
}
=>
define <4 x i32> @extract_cond_type_mismatch.2(<4 x i32> %x, <5 x i1> %condv) {
#0:
%.splat = shufflevector <5 x i1> %condv, <5 x i1> poison, 1, 1, 1, 1
%r = select <4 x i1> %.splat, <4 x i32> %x, <4 x i32> { 0, 0, 0, 0 }
ret <4 x i32> %r
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
<4 x i32> %x = < #xffffffff (4294967295, -1), #x00000000 (0), #x00000000 (0), #x00008000 (32768) >
<5 x i1> %condv = < #x0 (0) [based on undef value], undef, #x0 (0) [based on undef value], #x0 (0) [based on undef value], #x0 (0) [based on undef value] >
Source:
i1 %cond = #x0 (0) [based on undef value]
i1 %#1 = #x0 (0)
<4 x i32> %r = < #x00000000 (0), #x00000000 (0), #x00000000 (0), #x00000000 (0) >
Target:
<4 x i1> %.splat = < #x0 (0), #x0 (0), #x0 (0), #x1 (1) >
<4 x i32> %r = < #x00000000 (0), #x00000000 (0), #x00000000 (0), #x00008000 (32768) >
Source value: < #x00000000 (0), #x00000000 (0), #x00000000 (0), #x00000000 (0) >
Target value: < #x00000000 (0), #x00000000 (0), #x00000000 (0), #x00008000 (32768) >
----------------------------------------
define <4 x i32> @extract_cond.2(<4 x i32> %x, <4 x i1> %condv) {
#0:
%cond = extractelement <4 x i1> %condv, i32 3
%r = select i1 %cond, <4 x i32> %x, <4 x i32> { 0, 0, 0, 0 }
ret <4 x i32> %r
}
=>
define <4 x i32> @extract_cond.2(<4 x i32> %x, <4 x i1> %condv) {
#0:
%.splat = shufflevector <4 x i1> %condv, <4 x i1> poison, 3, 3, 3, 3
%r = select <4 x i1> %.splat, <4 x i32> %x, <4 x i32> { 0, 0, 0, 0 }
ret <4 x i32> %r
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
<4 x i32> %x = < #x00000002 (2), #x00000000 (0), #xffffffff (4294967295, -1), #x00000000 (0) >
<4 x i1> %condv = < #x0 (0) [based on undef value], #x0 (0) [based on undef value], #x0 (0) [based on undef value], undef >
Source:
i1 %cond = #x0 (0) [based on undef value]
<4 x i32> %r = < #x00000000 (0), #x00000000 (0), #x00000000 (0), #x00000000 (0) >
Target:
<4 x i1> %.splat = < #x1 (1), #x0 (0), #x0 (0), #x0 (0) >
<4 x i32> %r = < #x00000002 (2), #x00000000 (0), #x00000000 (0), #x00000000 (0) >
Source value: < #x00000000 (0), #x00000000 (0), #x00000000 (0), #x00000000 (0) >
Target value: < #x00000002 (2), #x00000000 (0), #x00000000 (0), #x00000000 (0) >
Summary:
0 correct transformations
2 incorrect transformations
0 failed-to-prove transformations
0 Alive2 errors
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWN9v4jgQ_muGFwvkjPPzIQ8tFOl0K53UXe09Vk7sgHshRrbD0fvrT04CBVo4umqrPWmjlVeMx-P5vvH4U82tVYtGyhyiW4hmI966pTZ5oZvFY9s8jgotnvKlc2sL7AZwDjhfKLdsi0mpV4Dzut7s_huvjX6UpQOcF7UuAOeRCDkVUVhEGGcFF0EYUBmLI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