Skip to content

Commit 7bf89c2

Browse files
committed
[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
1 parent 0fe4b8e commit 7bf89c2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

llvm/lib/Transforms/Scalar/Reassociate.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,6 @@ static bool isLoadCombineCandidate(Instruction *Or) {
976976

977977
/// Return true if it may be profitable to convert this (X|Y) into (X+Y).
978978
static bool ShouldConvertOrWithNoCommonBitsToAdd(Instruction *Or) {
979-
// If this `or` appears to be a part of an load widening reduction, ignore it.
980-
if (isLoadCombineCandidate(Or))
981-
return false;
982-
983979
// Don't bother to convert this up unless either the LHS is an associable add
984980
// or subtract or mul or if this is only used by one of the above.
985981
// This is only a compile-time improvement, it is not needed for correctness!
@@ -2217,7 +2213,7 @@ void ReassociatePass::OptimizeInst(Instruction *I) {
22172213
// If this is a bitwise or instruction of operands
22182214
// with no common bits set, convert it to X+Y.
22192215
if (I->getOpcode() == Instruction::Or &&
2220-
ShouldConvertOrWithNoCommonBitsToAdd(I) &&
2216+
ShouldConvertOrWithNoCommonBitsToAdd(I) && !isLoadCombineCandidate(I) &&
22212217
haveNoCommonBitsSet(I->getOperand(0), I->getOperand(1),
22222218
I->getModule()->getDataLayout(), /*AC=*/nullptr, I,
22232219
/*DT=*/nullptr)) {

0 commit comments

Comments
 (0)