Issue 114355
Summary [InstCombine] wrong folding of `shufflevector` with a binary operator
Labels new issue
Assignees
Reporter bongjunj
    https://github.com/llvm/llvm-project/blob/6effab990c5c1b4fe55fcd43004a1fd88145bb8d/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L2228-L2240

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

```llvm
----------------------------------------
define <2 x i16> @test_srem_orig.2(i16 %a, i1 %cmp) {
#0:
  %splatinsert = insertelement <2 x i16> { 65535, poison }, i16 %a, i32 0
  %splat = shufflevector <2 x i16> %splatinsert, <2 x i16> undef, 0, 0
  %t1 = select i1 %cmp, <2 x i16> { 65535, poison }, <2 x i16> %splat
  %#1 = xor <2 x i16> %t1, { 2, 2 }
  ret <2 x i16> %#1
}
=>
define <2 x i16> @test_srem_orig.2(i16 %a, i1 %cmp) {
#0:
  %splatinsert = insertelement <2 x i16> poison, i16 %a, i64 0
  %#1 = xor <2 x i16> %splatinsert, { 2, poison }
  %#2 = shufflevector <2 x i16> %#1, <2 x i16> poison, 0, 0
 %#3 = select i1 %cmp, <2 x i16> { 65533, poison }, <2 x i16> %#2
  ret <2 x i16> %#3
}
Transformation doesn't verify!

ERROR: Target's return value is more undefined

Example:
i16 %a = #x0000 (0)
i1 %cmp = undef

Source:
<2 x i16> %splatinsert = < #x0000 (0), poison >
<2 x i16> %splat = < #x0000 (0), #x0000 (0) >
<2 x i16> %t1 = < #x0000 (0)	[based on undef value], #x0000 (0) >
<2 x i16> %#1 = < #x0002 (2), #x0002 (2) >

Target:
<2 x i16> %splatinsert = < #x0000 (0), poison >
<2 x i16> %#1 = < #x0002 (2), poison >
<2 x i16> %#2 = < #x0002 (2), #x0002 (2) >
<2 x i16> %#3 = < #x0002 (2), #x0002 (2) >
Source value: < #x0002 (2), #x0002 (2) >
Target value: < #x0002 (2), #x0002 (2) >


----------------------------------------
define <2 x i16> @test_srem_orig.3(i16 %a, i1 %cmp) {
#0:
  %splatinsert = insertelement <2 x i16> poison, i16 %a, i32 0
  %splat = shufflevector <2 x i16> %splatinsert, <2 x i16> poison, 0, 0
  %t1 = select i1 %cmp, <2 x i16> { undef, 65535 }, <2 x i16> %splat
  %t2 = srem <2 x i16> %t1, { 2, 2 }
  ret <2 x i16> %t2
}
=>
define <2 x i16> @test_srem_orig.3(i16 %a, i1 %cmp) {
#0:
  %splatinsert = insertelement <2 x i16> poison, i16 %a, i64 0
  %#1 = srem <2 x i16> %splatinsert, { 2, 1 }
  %#2 = shufflevector <2 x i16> %#1, <2 x i16> poison, 0, 0
  %t2 = select i1 %cmp, <2 x i16> { 0, 65535 }, <2 x i16> %#2
  ret <2 x i16> %t2
}
Transformation doesn't verify!

ERROR: Target's return value is more undefined

Example:
i16 %a = #x0001 (1)
i1 %cmp = undef

Source:
<2 x i16> %splatinsert = < #x0001 (1), poison >
<2 x i16> %splat = < #x0001 (1), #x0001 (1) >
<2 x i16> %t1 = < #x0001 (1)	[based on undef value], #x0001 (1) >
<2 x i16> %t2 = < #x0001 (1), #x0001 (1) >

Target:
<2 x i16> %splatinsert = < #x0001 (1), poison >
<2 x i16> %#1 = < #x0001 (1), poison >
<2 x i16> %#2 = < #x0001 (1), #x0001 (1) >
<2 x i16> %t2 = < #x0001 (1), #x0001 (1) >
Source value: < #x0001 (1), #x0001 (1) >
Target value: < #x0001 (1), #x0001 (1) >

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