[llvm] 2310e3e - [GlobalISel] Move DemandedElt's APInt size assert after isValid() check (#115979)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 18 15:39:32 PST 2024
Author: Daniel Sanders
Date: 2024-11-18T15:39:28-08:00
New Revision: 2310e3e3f2ccdab156abc7f9d186b2605027d8fe
URL: https://github.com/llvm/llvm-project/commit/2310e3e3f2ccdab156abc7f9d186b2605027d8fe
DIFF: https://github.com/llvm/llvm-project/commit/2310e3e3f2ccdab156abc7f9d186b2605027d8fe.diff
LOG: [GlobalISel] Move DemandedElt's APInt size assert after isValid() check (#115979)
This prevents the assertion from wrongly triggering on invalid LLT's
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
index 40d4a5250dfbbd..a700d866afa4ec 100644
--- a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
@@ -147,6 +147,15 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
unsigned Opcode = MI.getOpcode();
LLT DstTy = MRI.getType(R);
+ // Handle the case where this is called on a register that does not have a
+ // type constraint (i.e. it has a register class constraint instead). This is
+ // unlikely to occur except by looking through copies but it is possible for
+ // the initial register being queried to be in this state.
+ if (!DstTy.isValid()) {
+ Known = KnownBits();
+ return;
+ }
+
#ifndef NDEBUG
if (DstTy.isFixedVector()) {
assert(
@@ -158,15 +167,6 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
}
#endif
- // Handle the case where this is called on a register that does not have a
- // type constraint (i.e. it has a register class constraint instead). This is
- // unlikely to occur except by looking through copies but it is possible for
- // the initial register being queried to be in this state.
- if (!DstTy.isValid()) {
- Known = KnownBits();
- return;
- }
-
unsigned BitWidth = DstTy.getScalarSizeInBits();
auto CacheEntry = ComputeKnownBitsCache.find(R);
if (CacheEntry != ComputeKnownBitsCache.end()) {
More information about the llvm-commits
mailing list