Issue 113867
Summary Can't splat undefined conditions
Labels new issue
Assignees
Reporter bongjunj
    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
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to