Skip to content

Commit 2310e3e

Browse files
authored
[GlobalISel] Move DemandedElt's APInt size assert after isValid() check (#115979)
This prevents the assertion from wrongly triggering on invalid LLT's
1 parent dc087d1 commit 2310e3e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
147147
unsigned Opcode = MI.getOpcode();
148148
LLT DstTy = MRI.getType(R);
149149

150+
// Handle the case where this is called on a register that does not have a
151+
// type constraint (i.e. it has a register class constraint instead). This is
152+
// unlikely to occur except by looking through copies but it is possible for
153+
// the initial register being queried to be in this state.
154+
if (!DstTy.isValid()) {
155+
Known = KnownBits();
156+
return;
157+
}
158+
150159
#ifndef NDEBUG
151160
if (DstTy.isFixedVector()) {
152161
assert(
@@ -158,15 +167,6 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
158167
}
159168
#endif
160169

161-
// Handle the case where this is called on a register that does not have a
162-
// type constraint (i.e. it has a register class constraint instead). This is
163-
// unlikely to occur except by looking through copies but it is possible for
164-
// the initial register being queried to be in this state.
165-
if (!DstTy.isValid()) {
166-
Known = KnownBits();
167-
return;
168-
}
169-
170170
unsigned BitWidth = DstTy.getScalarSizeInBits();
171171
auto CacheEntry = ComputeKnownBitsCache.find(R);
172172
if (CacheEntry != ComputeKnownBitsCache.end()) {

0 commit comments

Comments
 (0)