[llvm] ec3f24d - [InstCombine] recognizeBSwapOrBitReverseIdiom - assert for correct bit providence indices. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 04:00:59 PDT 2020


Author: Simon Pilgrim
Date: 2020-09-30T11:16:33+01:00
New Revision: ec3f24d4538d1c262377331c7b35ea66e023cf98

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

LOG: [InstCombine] recognizeBSwapOrBitReverseIdiom - assert for correct bit providence indices. NFCI.

As suggested by @spatel on D88316

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 61f4dffb641c..8ff11ba4cab4 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3027,6 +3027,9 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
   if (!Res)
     return false;
   auto &BitProvenance = Res->Provenance;
+  assert(all_of(BitProvenance,
+                [](int8_t I) { return I == BitPart::Unset || 0 <= I; }) &&
+         "Illegal bit provenance index");
 
   // Now, is the bit permutation correct for a bswap or a bitreverse? We can
   // only byteswap values with an even number of bytes.


        


More information about the llvm-commits mailing list