[PATCH] D30537: [DAGCombiner] allow transforming (select Cond, C +/- 1, C) to (add(ext Cond), C)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 15:27:38 PST 2017


spatel added a comment.

In https://reviews.llvm.org/D30537#690878, @efriedma wrote:

> All of the testcase changes you're showing here involve a select where the condition is a TRUNCATE (so the extension is free, so it's profitable to transform on all platforms).  Does this have any impact on the more common patterns, like SELECT(SETCC)?


Excellent question...

For x86, if we have a setcc node, then everything I've tried so far that would be affected by this patch would also be caught in the target-specific combineSelectOfTwoConstants(), so there's no output difference.

For PPC, the code in this patch will fire too, but there is code that reverses the transform:

  PPC DAG preprocessing replacing:
  Old:    t20: i64 = add t19, Constant:i64<41>
  New: t28: i64 = select t8, Constant:i64<42>, Constant:i64<41>

...so <tears forming>, we end up with isel -- or worse cmp/br. And so again, there is no output difference.

So the answer to your question for x86 and PPC (for different reasons) is: no, there is no impact on the common cases AFAICT.


https://reviews.llvm.org/D30537





More information about the llvm-commits mailing list