| Issue |
114358
|
| Summary |
[InstCombine] wrong folding of an extension and a binary operator for undefined inputs
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
bongjunj
|
https://github.com/llvm/llvm-project/blob/a33fd61862efc03cfde2cc84c2a2d6f7f1c55983/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L2336-L2346
Alive2 report: https://alive2.llvm.org/ce/z/dt_Cji
```llvm
----------------------------------------
define i32 @test8_vec.3(i16 %V) {
#0:
%ashr = ashr i16 %V, 8
%sext = sext i16 %ashr to i32
%#1 = sext i16 %ashr to i32
%mul = mul i32 %sext, %#1
ret i32 %mul
}
=>
define i32 @test8_vec.3(i16 %V) {
#0:
%ashr = ashr i16 %V, 8
%narrow = mul nsw i16 %ashr, %ashr
%mul = zext nneg i16 %narrow to i32
ret i32 %mul
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
i16 %V = undef
Source:
i16 %ashr = #x0000 (0) [based on undef value]
i32 %sext = #x00000000 (0)
i32 %#1 = #x00000000 (0) [based on undef value]
i32 %mul = #x00000000 (0)
Target:
i16 %ashr = #x0018 (24)
i16 %narrow = #xf400 (62464, -3072)
i32 %mul = poison
Source value: #x00000000 (0)
Target value: poison
----------------------------------------
define <2 x i32> @test8_vec.2(<2 x i16> %V) {
#0:
%ashr = ashr <2 x i16> %V, { 8, 8 }
%sext = sext <2 x i16> %ashr to <2 x i32>
%#1 = sext <2 x i16> %ashr to <2 x i32>
%mul = mul <2 x i32> %sext, %#1
ret <2 x i32> %mul
}
=>
define <2 x i32> @test8_vec.2(<2 x i16> %V) {
#0:
%ashr = ashr <2 x i16> %V, { 8, 8 }
%narrow = mul nsw <2 x i16> %ashr, %ashr
%mul = zext nneg <2 x i16> %narrow to <2 x i32>
ret <2 x i32> %mul
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
<2 x i16> %V = < #x0000 (0), undef >
Source:
<2 x i16> %ashr = < #x0000 (0), #x0000 (0) [based on undef value] >
<2 x i32> %sext = < #x00000000 (0), #x00000000 (0) >
<2 x i32> %#1 = < #x00000000 (0), #x00000000 (0) [based on undef value] >
<2 x i32> %mul = < #x00000000 (0), #x00000000 (0) >
Target:
<2 x i16> %ashr = < #x0000 (0), #xff80 (65408, -128) >
<2 x i16> %narrow = < #x0000 (0), #xfc00 (64512, -1024) >
<2 x i32> %mul = < #x00000000 (0), poison >
Source value: < #x00000000 (0), #x00000000 (0) >
Target value: < #x00000000 (0), poison >
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