Issue 113990
Summary Wrong case of `select` folding of symmetric select
Labels new issue
Assignees
Reporter bongjunj
    https://github.com/llvm/llvm-project/blob/1ceccbb0dd9d8539fec2213566fe6cc2a05b7993/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L3009-L3033

Alive2 report: https://alive2.llvm.org/ce/z/qq8xsz

```llvm
----------------------------------------
define <4 x i32> @select_of_symmetric_selects_vector1.2(<4 x i32> %a, <4 x i32> %b, i1 %c1, i1 %c2) {
#0:
  %sel1 = select i1 %c1, <4 x i32> %a, <4 x i32> %b
  %sel2 = select i1 %c1, <4 x i32> %b, <4 x i32> %a
  %#1 = xor i1 %c1, undef
  %#2 = select i1 %c1, i1 %#1, i1 %c2
  %ret = select i1 %#2, <4 x i32> %sel2, <4 x i32> %sel1
  ret <4 x i32> %ret
}
=>
define <4 x i32> @select_of_symmetric_selects_vector1.2(<4 x i32> %a, <4 x i32> %b, i1 %c1, i1 %c2) {
#0:
  %#1 = select i1 %c1, i1 undef, i1 %c2
  %#2 = xor i1 %c1, %#1
  %ret = select i1 %#2, <4 x i32> %a, <4 x i32> %b
  ret <4 x i32> %ret
}
Transformation doesn't verify!

ERROR: Target's return value is more undefined

Example:
<4 x i32> %a = < #x00000000 (0), #x00000000 (0), undef, #x00000000 (0) >
<4 x i32> %b = < #x00000000 (0), #x00000800 (2048), #x00000003 (3), #x00000000 (0) >
i1 %c1 = undef
i1 %c2 = #x0 (0)

Source:
<4 x i32> %sel1 = < #x00000000 (0), #x00000800 (2048), #x00000003 (3), #x00000000 (0) >
<4 x i32> %sel2 = < #x00000000 (0), #x00000000 (0), #x00000000 (0)	[based on undef value], #x00000000 (0) >
i1 %#1 = #x0 (0)	[based on undef value]
i1 %#2 = #x0 (0)
<4 x i32> %ret = < #x00000000 (0), #x00000800 (2048), #x00000003 (3), #x00000000 (0) >

Target:
i1 %#1 = #x0 (0)
i1 %#2 = #x1 (1)
<4 x i32> %ret = < #x00000000 (0), #x00000000 (0), #x9193a504 (2442372356, -1852594940), #x00000000 (0) >
Source value: < #x00000000 (0), #x00000800 (2048), #x00000003 (3), #x00000000 (0) >
Target value: < #x00000000 (0), #x00000000 (0), #x9193a504 (2442372356, -1852594940), #x00000000 (0) >

Summary:
  0 correct transformations
  1 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