[PATCH] D18841: [InstCombine] Canonicalize icmp instructions based on dominating conditions.
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 14:19:17 PDT 2016
sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.
This looks okay to me (pending the one inline comment), assuming @majnemer is fine with too.
Btw, looks like instcombine already canonicalizes towards equality, for instance:
define i1 @f(i32 %x) {
%v = icmp ugt i32 %x, 0
ret i1 %v
}
is instcombined to
define i1 @f(i32 %x) {
%v = icmp ne i32 %x, 0
ret i1 %v
}
and this change looks like it is doing more of the same.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3287
@@ +3286,3 @@
+ auto *BI =
+ Dom ? dyn_cast_or_null<BranchInst>(Dom->getTerminator()) : nullptr;
+ ICmpInst::Predicate Pred;
----------------
I think you can just use `dyn_cast` here. For a well formed CFG, `getTerminator` should always return `nonnull`.
http://reviews.llvm.org/D18841
More information about the llvm-commits
mailing list