Skip to content

Commit fa0971b

Browse files
TNorthoveraemerson
authored andcommittedApr 9, 2021
GlobalISel: check type size before getZExtValue()ing it.
Otherwise getZExtValue() asserts. (cherry picked from commit c2b322f)
1 parent d28af7c commit fa0971b

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed
 

‎llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,8 @@ void IRTranslator::emitSwitchCase(SwitchCG::CaseBlock &CB,
840840
// For conditional branch lowering, we might try to do something silly like
841841
// emit an G_ICMP to compare an existing G_ICMP i1 result with true. If so,
842842
// just re-use the existing condition vreg.
843-
if (CI && CI->getZExtValue() == 1 &&
844-
MRI->getType(CondLHS).getSizeInBits() == 1 &&
845-
CB.PredInfo.Pred == CmpInst::ICMP_EQ) {
843+
if (MRI->getType(CondLHS).getSizeInBits() == 1 && CI &&
844+
CI->getZExtValue() == 1 && CB.PredInfo.Pred == CmpInst::ICMP_EQ) {
846845
Cond = CondLHS;
847846
} else {
848847
Register CondRHS = getOrCreateVReg(*CB.CmpRHS);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: llc -mtriple=arm64-apple-ios %s -o - -O0 -global-isel=1 | FileCheck %s
2+
define void @foo(i512 %in) {
3+
; CHECK-LABEL: foo:
4+
; CHECK: cbz
5+
switch i512 %in, label %default [
6+
i512 3923188584616675477397368389504791510063972152790021570560, label %l1
7+
i512 3923188584616675477397368389504791510063972152790021570561, label %l2
8+
i512 3923188584616675477397368389504791510063972152790021570562, label %l3
9+
]
10+
11+
default:
12+
ret void
13+
14+
l1:
15+
ret void
16+
17+
l2:
18+
ret void
19+
20+
l3:
21+
ret void
22+
}

0 commit comments

Comments
 (0)