[InstCombine] recognizeBSwapOrBitReverseIdiom - assert for correct bit providence...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 30 Sep 2020 10:13:54 +0000 (11:13 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Wed, 30 Sep 2020 10:16:33 +0000 (11:16 +0100)
As suggested by @spatel on D88316

llvm/lib/Transforms/Utils/Local.cpp

index 61f4dff..8ff11ba 100644 (file)
@@ -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.