[PATCH] D74228: [PatternMatch] Match XOR variant of unsigned-add overflow check.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 14:46:34 PST 2020


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


================
Comment at: llvm/include/llvm/IR/PatternMatch.h:2055
+      Value *Op1;
+      if (m_OneUse(m_c_Xor(m_Value(Op1), m_AllOnes())).match(ICmpLHS))
+        return L.match(Op1) && R.match(ICmpRHS) && S.match(ICmpLHS);
----------------
lebedev.ri wrote:
> We know constant is always on rhs of binop.
> I was talking about `b u> (a ^ -1)` case there.
> 
> Also, not strictly related to this patch, but does this simply ignore inverted cases, like `(a ^ -1) u>= b`?
> I was talking about b u> (a ^ -1) case there.

Right, that should be fixed in the latest version. I've updated `replaceMathCmpWithIntrinsic` to take the A and B args directly, rather than getting it from the BO, because with Xor that's not straight forward.


> Also, not strictly related to this patch, but does this simply ignore inverted cases, like (a ^ -1) u>= b?

For now yes. Not sure how common that is, but it could be added as follow-up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74228





More information about the llvm-commits mailing list