[PATCH] D154937: [InstCombine] Generalize foldAndOrOfICmpEqZeroAndICmp
    Nikita Popov via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Jul 11 03:32:17 PDT 2023
    
    
  
nikic added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3001
 
+  Constant *C = ConstantInt::get(LHS0->getType(), *CInt);
+
----------------
Move this lower, not needed here yet.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:3022
+      Builder.CreateSub(
+          LHS0, Builder.CreateAdd(C, ConstantInt::get(LHS0->getType(), 1))),
       Other);
----------------
Create the constant directly from `*CInt + 1`, no need for CreateAdd.
================
Comment at: llvm/test/Transforms/InstCombine/and-or-icmp-const-icmp.ll:84
 ;
   %sub = sub i8 %x, 5
   %c1 = icmp eq i8 %x, 6
----------------
Write this in canonical form (add -5) or drop the test if redundant with the next.
================
Comment at: llvm/test/Transforms/InstCombine/and-or-icmp-const-icmp.ll:259
-; CHECK-NEXT:    [[C1:%.*]] = icmp eq i8 [[X]], -1
-; CHECK-NEXT:    [[C2:%.*]] = icmp ugt i8 [[ADD]], [[Y]]
-; CHECK-NEXT:    [[OR:%.*]] = or i1 [[C1]], [[C2]]
----------------
Not actually commuted. Grep for `thwart complexity-based canonicalization` in tests.
================
Comment at: llvm/test/Transforms/InstCombine/and-or-icmp-const-icmp.ll:270
 
 define <2 x i1> @eq_vetor_commuted(<2 x i8> %x, <2 x i8> %y) {
 ; CHECK-LABEL: define <2 x i1> @eq_vetor_commuted
----------------
No need for separate commuted vector tests.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154937/new/
https://reviews.llvm.org/D154937
    
    
More information about the llvm-commits
mailing list