[llvm] 5dde755 - [AggressiveInstCombine][NFC] Fix typo

Maksim Kita via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 7 11:58:51 PDT 2023


Author: Maksim Kita
Date: 2023-08-07T21:51:44+03:00
New Revision: 5dde755188e34c0ba5304365612904476c8adfda

URL: https://github.com/llvm/llvm-project/commit/5dde755188e34c0ba5304365612904476c8adfda
DIFF: https://github.com/llvm/llvm-project/commit/5dde755188e34c0ba5304365612904476c8adfda.diff

LOG: [AggressiveInstCombine][NFC] Fix typo

AggressiveInstCombine fix typo in expandStrcmp method.

Differential Revision: https://reviews.llvm.org/D156556

Added: 
    

Modified: 
    llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index 41f33c31f83977..341107236d7911 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -934,13 +934,8 @@ static bool expandStrcmp(CallInst *CI, DominatorTree &DT, bool &MadeCFGChange) {
   size_t ConstantStrSize = ConstantStr.size();
 
   // Trivial cases are optimized during inst combine
-  if (ConstantStrSize == 0) {
+  if (ConstantStrSize == 0 || ConstantStrSize > 2)
     return false;
-  }
-
-  if (ConstantStrSize > 2) {
-    return false;
-  }
 
   // Check if strcmp result is only used in a comparison with zero
   if (!isOnlyUsedInZeroComparison(CI))
@@ -960,7 +955,7 @@ static bool expandStrcmp(CallInst *CI, DominatorTree &DT, bool &MadeCFGChange) {
   // For strcmp(P, "xy") do the following transformation:
   //
   // (before)
-  // dst = strcmp(P, "x")
+  // dst = strcmp(P, "xy")
   //
   // (after)
   // v0 = P[0] - 'x'
@@ -1000,19 +995,19 @@ static bool expandStrcmp(CallInst *CI, DominatorTree &DT, bool &MadeCFGChange) {
         static_cast<unsigned char>(ConstantStr[CharacterIndexToCheck]));
     Value *CharacterSub =
         B.CreateNSWSub(StrCharacterValue, ConstantStrCharacterValue);
-    Value *IsCharacterSubZero =
+    Value *CharacterSubIsZero =
         B.CreateICmpEQ(CharacterSub, ConstantInt::get(RetType, 0));
-    BasicBlock *IsCharacterSubZeroBB =
+    BasicBlock *CharacterSubIsZeroBB =
         BasicBlock::Create(B.getContext(), "strcmp_expand_sub_is_zero",
                            InitialBB->getParent(), JoinBlock);
-    B.CreateCondBr(IsCharacterSubZero, IsCharacterSubZeroBB, JoinBlock);
+    B.CreateCondBr(CharacterSubIsZero, CharacterSubIsZeroBB, JoinBlock);
 
     ResultPHI->addIncoming(CharacterSub, B.GetInsertBlock());
     DTUpdates.emplace_back(DominatorTree::Insert, B.GetInsertBlock(),
-                           IsCharacterSubZeroBB);
+                           CharacterSubIsZeroBB);
 
-    B.SetInsertPoint(IsCharacterSubZeroBB);
-    DTUpdates.emplace_back(DominatorTree::Insert, IsCharacterSubZeroBB,
+    B.SetInsertPoint(CharacterSubIsZeroBB);
+    DTUpdates.emplace_back(DominatorTree::Insert, CharacterSubIsZeroBB,
                            JoinBlock);
   }
 


        


More information about the llvm-commits mailing list