[PATCH] D67356: [InstCombine] Simplify @llvm.usub.with.overflow+non-zero check (PR43251)

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 13:51:17 PDT 2019


xbolva00 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2249
+  if (Value *X = foldUnsignedUnderflowCheck(RHS, LHS, /*IsAnd=*/false, Builder))
+    return X;
+
----------------
lebedev.ri wrote:
> vsk wrote:
> > lebedev.ri wrote:
> > > vsk wrote:
> > > > Does the 'or of icmps' case arise anywhere?
> > > Define arise. We can trivially get one from another via De Morgan laws:
> > > `(a && b) ? c : d` <--> `!(a && b) ? d : c` <--> `(!a || !b) ? d : c`,
> > > It's *really* bad idea to intentionally not handle such nearby patterns.
> > > 
> > As in, do unsigned underflow checks tend to contain this specific or-of-icmp pattern, or more generally whether programs in the wild tend to.
> > 
> > If this isn't the case, then it seems like there's a compile-time cost for optimizing the pattern without any compensating benefit.
> I'm not sure what the question is.
If a compile time cost is concern, put it to AgressiveInstCombine - but I dont think we should do it in this case since there is nothing expensive like ValueTracking here..

I like Roman’s current code as is.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67356





More information about the llvm-commits mailing list