[PATCH] D89317: [InstructionSimplify] icmp simplification

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 03:11:57 PDT 2020


SjoerdMeijer added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:2870-2871
+  // Canonicalize nsw add as RHS.
+  if (!match(RHS, m_NSWAdd(m_Value(), m_Value())))
+    std::swap(LHS, RHS);
+  if (!match(RHS, m_NSWAdd(m_Value(), m_Value())))
----------------
spatel wrote:
> I think this works, but I'm worried that it could break if we are not careful.
> If we are swapping the operands, should we also swap the predicate, and then check if it is SLT after the swap?
Yep, more predicates could be supported here, but I thought to have a start with SLT first, hence the `Pred != CmpInst::ICMP_SLT` check above on line 2866, so should be fine for now?


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

https://reviews.llvm.org/D89317



More information about the llvm-commits mailing list