[PATCH] D15232: [InstCombine] Aggressively fold compares that can be discovered to be constant
hfinkel@anl.gov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 10 07:14:50 PST 2015
hfinkel added a comment.
Can you provide a better example, because InstCombine seems to get the one you mentioned already (I just tried with a build using r254106):
$ cat /tmp/f.cpp
bool check(bool i) {
int f = i ? 42 : 64;
f += 1;
return f > 78;
}
which eventually gets down to:
define zeroext i1 @_Z5checkb(i1 zeroext %i) #0 {
entry:
%frombool = zext i1 %i to i8
%tobool = trunc i8 %frombool to i1
%cond = select i1 %tobool, i32 42, i32 64
%add = add nsw i32 %cond, 1
%cmp = icmp sgt i32 %add, 78
ret i1 %cmp
}
and then (after instcombine):
; Function Attrs: nounwind
define zeroext i1 @_Z5checkb(i1 zeroext %i) #0 {
entry:
ret i1 false
}
Beyond this, if we need further functionality in instcombine, did you consider using LVI directly?
http://reviews.llvm.org/D15232
More information about the llvm-commits
mailing list