Issue |
91691
|
Summary |
instcombine removes a select, making code more poisonous
|
Labels |
miscompilation,
llvm:instcombine
|
Assignees |
|
Reporter |
regehr
|
https://alive2.llvm.org/ce/z/c__jy8
this function:
```llvm
define i32 @f(i32 %0) {
%2 = sub nuw i32 -2, %0
%3 = tail call i32 @llvm.ctlz.i32(i32 %2, i1 false)
%4 = sub i32 32, %3
%5 = shl i32 1, %4
%6 = icmp ult i32 %0, -2
%7 = select i1 %6, i32 %5, i32 1
ret i32 %7
}
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctlz.i32(i32, i1 immarg) #0
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
```
is getting rewritten to not have the select, but the select was blocking a poison value. the bad thing happens when -1 is passed as an argument.
```llvm
define i32 @f(i32 %0) {
%2 = sub nuw i32 -2, %0
%3 = tail call range(i32 0, 33) i32 @llvm.ctlz.i32(i32 %2, i1 false)
%4 = sub nsw i32 0, %3
%5 = and i32 %4, 31
%6 = shl nuw i32 1, %5
ret i32 %6
}
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.ctlz.i32(i32, i1 immarg) #0
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
```
cc @nunoplopes
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs