[PATCH] D156556: [AggressiveInstCombine][NFC] Fix typo

Maksim Kita via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 2 03:25:32 PDT 2023


kitaisreal updated this revision to Diff 546386.
kitaisreal added a comment.

Uploaded correct patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156556

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


Index: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
===================================================================
--- llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -934,13 +934,8 @@
   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 @@
   // 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_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);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156556.546386.patch
Type: text/x-patch
Size: 2100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230802/1f7c9438/attachment.bin>


More information about the cfe-commits mailing list