From 881bf715f06201a57a4f1a60155b556fedd556db Mon Sep 17 00:00:00 2001 From: Victor Mustya Date: Tue, 22 Aug 2023 11:10:30 -0700 Subject: [PATCH] Don't emit bitreverse or bswap intrinsics of illegal bit width during instcombine --- llvm/lib/Transforms/Utils/Local.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 2f1d0c2f9..68f792bb0 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -3196,6 +3196,10 @@ bool llvm::recognizeBSwapOrBitReverseIdiom( if (DemandedBW > ITy->getScalarSizeInBits()) return false; + auto &DL = I->getModule()->getDataLayout(); + if (DL.isIllegalInteger(DemandedBW)) + return false; + // Now, is the bit permutation correct for a bswap or a bitreverse? We can // only byteswap values with an even number of bytes. APInt DemandedMask = APInt::getAllOnes(DemandedBW); -- 2.34.1