From ec3f24d4538d1c262377331c7b35ea66e023cf98 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 30 Sep 2020 11:13:54 +0100 Subject: [PATCH] [InstCombine] recognizeBSwapOrBitReverseIdiom - assert for correct bit providence indices. NFCI. As suggested by @spatel on D88316 --- llvm/lib/Transforms/Utils/Local.cpp | 3 +++ 1 file changed, 3 insertions(+) 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.