[PATCH] D78430: [InstSimplify] fold and/or of compares with equality to min/max constant
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 20 10:16:38 PDT 2020
aqjune added inline comments.
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:1689
+ else if (isa<ConstantPointerNull>(Cmp0->getOperand(1)))
+ MinMaxC = APInt::getNullValue(1);
+ else
----------------
The patch transforms this function into `ret false`, which is not correct. If %a = 0x0 and %b = 0x1, the source program should be true.
```
define i1 @f(i8* %a, i8* %b) {
%c1 = icmp eq i8* %a, null
%c2 = icmp slt i8* %a, %b
%r = and i1 %c1, %c2
ret i1 %r
}
```
And I think this miscompilation is related with assigning 1-bit integer in this line.
The line 1713 `MinMaxC += APInt::getSignedMinValue(MinMaxC.getBitWidth());` will make `MinMaxC` full of one bits, and it makes if branch at line 1716 taken.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D78430/new/
https://reviews.llvm.org/D78430
More information about the llvm-commits
mailing list