| Issue |
114352
|
| Summary |
[InstCombine] shoudn't set `exact` on `shr (shl ...)` for undefined inputs
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
bongjunj
|
https://github.com/llvm/llvm-project/blob/6bf214b7c6d74ec581bc52a9142756a1d1df6df0/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp#L991-L995
Alive2 report: https://alive2.llvm.org/ce/z/q2vHmJ
```llvm
----------------------------------------
define i32 @t6_twoshifts.2(i32 %x, i8 %shamt) {
bb:
%#0 = ctpop i8 %shamt
%shamt_wide = sext i8 %#0 to i32
br label %work
work:
%n0 = shl i32 %x, %shamt_wide
%r = ashr i32 %n0, %shamt_wide
br label %end
end:
ret i32 %r
}
=>
define i32 @t6_twoshifts.2(i32 %x, i8 %shamt) {
bb:
br label %work
work:
br label %end
end:
%#0 = ctpop i8 %shamt
%#range_0_%#0 = !range i8 %#0, i8 0, i8 9
%shamt_wide = zext nneg i8 %#range_0_%#0 to i32
%n0 = shl i32 %x, %shamt_wide
%r = ashr exact i32 %n0, %shamt_wide
ret i32 %r
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
i32 %x = #x00000002 (2)
i8 %shamt = undef
Source:
i8 %#0 = #x00 (0) [based on undef value]
i32 %shamt_wide = #x00000000 (0)
>> Jump to %work
i32 %n0 = #x00000002 (2)
i32 %r = #x00000002 (2) [based on undef value]
>> Jump to %end
Target:
>> Jump to %work
>> Jump to %end
i8 %#0 = #x00 (0)
i8 %#range_0_%#0 = #x00 (0)
i32 %shamt_wide = #x00000000 (0)
i32 %n0 = #x00000002 (2)
i32 %r = poison
Source value: #x00000002 (2)
Target value: poison
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