[PATCH] PR19958 wrong code at -O1 and above on x86_64-linux-gnu (InstCombine)
Sanjay Patel
spatel at rotateright.com
Wed Jun 11 13:47:34 PDT 2014
Minor nit: fear the 80-column police
// (icmp eq/ne (ashr exact const2, A), const1) -> icmp eq/ne A, Log2(const2/const1)
This line's indentation looks wrong too:
return new ICmpInst(I.getPredicate(), A,
Major nit:
unsigned shift = Quotient.logBase2();
What if Quotient isn't power of 2?
I think this leads to miscompiled code:
$ cat 19958.ll
@a = common global i32 0, align 4
define i1 @main() {
%a = load i32* @a, align 4
%shr = lshr exact i32 80, %a
%cmp = icmp eq i32 %shr, 41 ; NOTE: non-power-of-2 comparison
ret i1 %cmp
}
$ ./opt 19958.ll -S | ./llc | ./clang -x assembler - -o a.out ; ./a.out ; echo $?
0
$ ./opt -instcombine 19958.ll -S | ./llc | ./clang -x assembler - -o a.out ; ./a.out ; echo $?
1
http://reviews.llvm.org/D4068
More information about the llvm-commits
mailing list