Files
intel-graphics-compiler/external/llvm/releases/17.0.0/patches_external/Don-t-emit-bitreverse-or-bswap-intrinsics-of-illegal.patch
Mielczarek, Aleksander 9d5bec3237 Additional LLVM patching
Add necessary LLVM patches.
2025-10-14 14:05:15 +02:00

29 lines
990 B
Diff

From 881bf715f06201a57a4f1a60155b556fedd556db Mon Sep 17 00:00:00 2001
From: Victor Mustya <victor.mustya@intel.com>
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 b2ed95b05..476a5c4c1 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3312,6 +3312,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.43.0