[PATCH] D47076: [InstCombine] choose 1 form of abs and nabs as canonical

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 18 09:24:25 PDT 2018


spatel created this revision.
spatel added reviewers: craig.topper, dmgreen, efriedma.
Herald added a subscriber: mcrosier.

We already do this for min/max (see the blob above the diff), so we should do the same for abs/nabs.
Compare with 0 and having the original argument as the true value of the select feels the most natural to me, but if someone prefers a different flavor, we could do that too.

This might solve the motivating cases for https://reviews.llvm.org/D47037 and https://reviews.llvm.org/D47041, but I think those patches still make sense. We can't guarantee this canonicalization if the icmp has more than one use.

I adjusted the shifty abs transform to the pattern here to make that transform more efficient.


https://reviews.llvm.org/D47076

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/abs-1.ll
  test/Transforms/InstCombine/abs_abs.ll
  test/Transforms/InstCombine/icmp.ll
  test/Transforms/InstCombine/max-of-nots.ll
  test/Transforms/InstCombine/select_meta.ll
  test/Transforms/InstSimplify/call-callconv.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47076.147531.patch
Type: text/x-patch
Size: 36864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180518/c9ebd82e/attachment.bin>


More information about the llvm-commits mailing list