[PATCH] D33242: [InstCombine] add motivational comment for tests; NFC

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 09:27:50 PDT 2017


spatel added a comment.

In https://reviews.llvm.org/D33242#756203, @davide wrote:

> The wording is OK. What kind of infloop are you talking about here? Can you please elaborate?


Consider that we have this canonicalization for branch conditions:

  if (FPred == FCmpInst::FCMP_ONE || FPred == FCmpInst::FCMP_OLE ||
      FPred == FCmpInst::FCMP_OGE) {
    FCmpInst *Cond = cast<FCmpInst>(BI.getCondition());
    Cond->setPredicate(FCmpInst::getInversePredicate(FPred));

I would assume that the same rule applies to a select condition; ie, why would we treat equivalent-functionality selects and branches any differently?

But currently, we have this opposite canonicalization for select conditions:

  // Canonicalize to use ordered comparisons by swapping the select
  // operands.
  //
  // e.g.
  // (X ugt Y) ? X : Y -> (X ole Y) ? Y : X

If we have tests for both of those patterns, then a proposed change of the canonicalization rules should show the conflict.
(On closer inspection, I don't think the FP test included here covers a potential conflict predicate...so we might want another test, but I'll see if I can find if a similar test already exists first.)


https://reviews.llvm.org/D33242





More information about the llvm-commits mailing list