[llvm] 7bf89c2 - [NFC][Reassociate] Delay checking isLoadCombineCandidate() until after ShouldConvertOrWithNoCommonBitsToAdd() but before haveNoCommonBitsSet()
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 18 12:57:44 PST 2020
Author: Roman Lebedev
Date: 2020-11-18T23:57:12+03:00
New Revision: 7bf89c2174f0b2a91a4f680b3246d432c135381b
URL: https://github.com/llvm/llvm-project/commit/7bf89c2174f0b2a91a4f680b3246d432c135381b
DIFF: https://github.com/llvm/llvm-project/commit/7bf89c2174f0b2a91a4f680b3246d432c135381b.diff
LOG: [NFC][Reassociate] Delay checking isLoadCombineCandidate() until after ShouldConvertOrWithNoCommonBitsToAdd() but before haveNoCommonBitsSet()
This appears to improve -O3 compile-time performance somewhat:
https://llvm-compile-time-tracker.com/compare.php?from=87369c626114ae17f4c637635c119e6de0856a9a&to=c04b8271e1609b0dfb20609b40844b0c4324517e&stat=instructions
It doesn't look like delaying it until after haveNoCommonBitsSet() is better:
https://llvm-compile-time-tracker.com/compare.php?from=c04b8271e1609b0dfb20609b40844b0c4324517e&to=b2943d450eaf41b5f76d2dc7350f0a279f64cd99&stat=instructions
Added:
Modified:
llvm/lib/Transforms/Scalar/Reassociate.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 252677906854..4f774bed1472 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -976,10 +976,6 @@ static bool isLoadCombineCandidate(Instruction *Or) {
/// Return true if it may be profitable to convert this (X|Y) into (X+Y).
static bool ShouldConvertOrWithNoCommonBitsToAdd(Instruction *Or) {
- // If this `or` appears to be a part of an load widening reduction, ignore it.
- if (isLoadCombineCandidate(Or))
- return false;
-
// Don't bother to convert this up unless either the LHS is an associable add
// or subtract or mul or if this is only used by one of the above.
// This is only a compile-time improvement, it is not needed for correctness!
@@ -2217,7 +2213,7 @@ void ReassociatePass::OptimizeInst(Instruction *I) {
// If this is a bitwise or instruction of operands
// with no common bits set, convert it to X+Y.
if (I->getOpcode() == Instruction::Or &&
- ShouldConvertOrWithNoCommonBitsToAdd(I) &&
+ ShouldConvertOrWithNoCommonBitsToAdd(I) && !isLoadCombineCandidate(I) &&
haveNoCommonBitsSet(I->getOperand(0), I->getOperand(1),
I->getModule()->getDataLayout(), /*AC=*/nullptr, I,
/*DT=*/nullptr)) {
More information about the llvm-commits
mailing list