[PATCH] D132989: [InstSimplify] Odd - X ==/!= X -> false/true

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 5 06:08:08 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:3243-3250
   if (LBO)
     if (Value *V = simplifyICmpWithBinOpOnLHS(Pred, LBO, RHS, Q, MaxRecurse))
       return V;
 
   if (RBO)
     if (Value *V = simplifyICmpWithBinOpOnLHS(
             ICmpInst::getSwappedPredicate(Pred), RBO, LHS, Q, MaxRecurse))
----------------
Can you add this match inside of simplifyICmpWithBinOpOnLHS()? Then the swapped pattern is handled automatically.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:3297
+  // (sub C, X) != X, C is odd  --> true
+  if ((LBO && LBO->getOperand(1) == RHS &&
+      match(LHS, m_Sub(m_APInt(C), m_Specific(RHS)))) || 
----------------
The nullptr and equality checks are redundant - that is handled by the match().


================
Comment at: llvm/test/Transforms/InstSimplify/icmp.ll:215
+
+define i1 @sub_false(i32 %x) {
+; CHECK-LABEL: @sub_false(
----------------
Please pre-commit the baseline tests and then update this patch so it shows the diffs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132989



More information about the llvm-commits mailing list