[PATCH] D69514: [InstCombine] Expand usub_sat patterns to handle constants

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 10:26:07 PST 2019


dmgreen marked an inline comment as done.
dmgreen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:722
   // afterwards.
-  if (!TrueVal->hasOneUse())
+  if (!TrueVal->hasOneUse() || !ICI->hasOneUse())
     return nullptr;
----------------
lebedev.ri wrote:
> Err, this isn't quite right. I should have been more specific.
> 
> We produce a single instruction `@llvm.usub.sat.`,
> so there shouldn't be a one-use check in general.
> 
> But we also may need to negate the result.
> So *if* we need to negate the result,
> *then* we need ensure that a *single* instruction
> goes away - **either** `icmp` **or** `sub`.
> 
OK. I see. I was thinking you were referring to assembly instructions being longer if the icmp had multiple uses.

There may be some benefit to making sure the output is actually smaller.

I've updated the code. Let me know if this was or wasn't what you were thinking.


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

https://reviews.llvm.org/D69514





More information about the llvm-commits mailing list