[llvm] 079bbea - [Local] collectBitParts - for bswap-only matches, limit shift amounts to whole bytes to reduce compile time.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 03:43:04 PDT 2021


Author: Simon Pilgrim
Date: 2021-05-14T11:42:52+01:00
New Revision: 079bbea2b20dbfd24e4df654bae1c4324dcde754

URL: https://github.com/llvm/llvm-project/commit/079bbea2b20dbfd24e4df654bae1c4324dcde754
DIFF: https://github.com/llvm/llvm-project/commit/079bbea2b20dbfd24e4df654bae1c4324dcde754.diff

LOG: [Local] collectBitParts - for bswap-only matches, limit shift amounts to whole bytes to reduce compile time.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/Local.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 1f0646da7dd8..1c1d46bf46cc 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2940,6 +2940,10 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
       if (BitShift.uge(BitWidth))
         return Result;
 
+      // For bswap-only, limit shift amounts to whole bytes, for an early exit.
+      if (!MatchBitReversals && (BitShift.getZExtValue() % 8) != 0)
+        return Result;
+
       const auto &Res =
           collectBitParts(X, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
       if (!Res)
@@ -3055,6 +3059,10 @@ collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
       if (cast<IntrinsicInst>(I)->getIntrinsicID() == Intrinsic::fshr)
         ModAmt = BitWidth - ModAmt;
 
+      // For bswap-only, limit shift amounts to whole bytes, for an early exit.
+      if (!MatchBitReversals && (ModAmt % 8) != 0)
+        return Result;
+
       const auto &LHS =
           collectBitParts(X, MatchBSwaps, MatchBitReversals, BPS, Depth + 1);
       const auto &RHS =


        


More information about the llvm-commits mailing list