[PATCH] D87188: [InstCombine] Canonicalize SPF to abs intrinc

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 12 11:35:14 PDT 2020


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:1070
                                         InstCombinerImpl &IC) {
   if (!Cmp.hasOneUse() || !isa<Constant>(Cmp.getOperand(1)))
     return nullptr;
----------------
nikic wrote:
> I'm wondering what to do about this one use check. Should we canonicalize even if the compare has other uses?
> 
> We are folding cmp+sub+select into abs or abs+sub. However, both cmp and sub can potentially have extra uses.
Here's how dropping the one use check would look like: https://gist.github.com/nikic/3dece504951cba82415fed2d6aa876bf

Nominally, we are only increasing instruction count for the combination of nabs with extra uses on both icmp and sub.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87188/new/

https://reviews.llvm.org/D87188



More information about the llvm-commits mailing list