Skip to content

Commit 5dde755

Browse files
committed
[AggressiveInstCombine][NFC] Fix typo
AggressiveInstCombine fix typo in expandStrcmp method. Differential Revision: https://reviews.llvm.org/D156556
1 parent bddaa35 commit 5dde755

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -934,13 +934,8 @@ static bool expandStrcmp(CallInst *CI, DominatorTree &DT, bool &MadeCFGChange) {
934934
size_t ConstantStrSize = ConstantStr.size();
935935

936936
// Trivial cases are optimized during inst combine
937-
if (ConstantStrSize == 0) {
937+
if (ConstantStrSize == 0 || ConstantStrSize > 2)
938938
return false;
939-
}
940-
941-
if (ConstantStrSize > 2) {
942-
return false;
943-
}
944939

945940
// Check if strcmp result is only used in a comparison with zero
946941
if (!isOnlyUsedInZeroComparison(CI))
@@ -960,7 +955,7 @@ static bool expandStrcmp(CallInst *CI, DominatorTree &DT, bool &MadeCFGChange) {
960955
// For strcmp(P, "xy") do the following transformation:
961956
//
962957
// (before)
963-
// dst = strcmp(P, "x")
958+
// dst = strcmp(P, "xy")
964959
//
965960
// (after)
966961
// v0 = P[0] - 'x'
@@ -1000,19 +995,19 @@ static bool expandStrcmp(CallInst *CI, DominatorTree &DT, bool &MadeCFGChange) {
1000995
static_cast<unsigned char>(ConstantStr[CharacterIndexToCheck]));
1001996
Value *CharacterSub =
1002997
B.CreateNSWSub(StrCharacterValue, ConstantStrCharacterValue);
1003-
Value *IsCharacterSubZero =
998+
Value *CharacterSubIsZero =
1004999
B.CreateICmpEQ(CharacterSub, ConstantInt::get(RetType, 0));
1005-
BasicBlock *IsCharacterSubZeroBB =
1000+
BasicBlock *CharacterSubIsZeroBB =
10061001
BasicBlock::Create(B.getContext(), "strcmp_expand_sub_is_zero",
10071002
InitialBB->getParent(), JoinBlock);
1008-
B.CreateCondBr(IsCharacterSubZero, IsCharacterSubZeroBB, JoinBlock);
1003+
B.CreateCondBr(CharacterSubIsZero, CharacterSubIsZeroBB, JoinBlock);
10091004

10101005
ResultPHI->addIncoming(CharacterSub, B.GetInsertBlock());
10111006
DTUpdates.emplace_back(DominatorTree::Insert, B.GetInsertBlock(),
1012-
IsCharacterSubZeroBB);
1007+
CharacterSubIsZeroBB);
10131008

1014-
B.SetInsertPoint(IsCharacterSubZeroBB);
1015-
DTUpdates.emplace_back(DominatorTree::Insert, IsCharacterSubZeroBB,
1009+
B.SetInsertPoint(CharacterSubIsZeroBB);
1010+
DTUpdates.emplace_back(DominatorTree::Insert, CharacterSubIsZeroBB,
10161011
JoinBlock);
10171012
}
10181013

0 commit comments

Comments
 (0)