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); }
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); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits