[PATCH] D34278: [InstCombine] Recognize and simplify three way comparison idioms
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 22 09:55:31 PDT 2017
mkazantsev added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2495
+ Value *Cond = Builder->getFalse();
+ if (TrueWhenLessThan)
+ Cond = Builder->CreateOr(Cond, Builder->CreateICmp(ICmpInst::ICMP_SLT, OrigLHS, OrigRHS));
----------------
anna wrote:
> mkazantsev wrote:
> > Is it possible that more than one of {TrueWhenLessThan, TrueWhenEqual, TrueWhenGreaterThan} is true?
> >
> > If no, please add an assertion on that and use "else if" below.
> > If yes, should we not consider this when creating conditions?
> Yes, more than one can be true at a time: this actually enumerates all the possible 8 combinations, because of the chaining of these ORs in `CreateOr`. We pass in the `Cond` as the parameter.
>
> (I actually liked this idea a lot: credit goes to Sanjoy in suggesting this in the original review).
>
> Please see the comment above the code, should I perhaps clarify it more?
>
>
I've re-read the comment and the code, and I think it's fine, I just didn't realize the idea from the very beginning.
https://reviews.llvm.org/D34278
More information about the llvm-commits
mailing list