Skip to content

Commit

Permalink
AArch64: bail instead of asserting on unexpected type in G_CONSTANT 0.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368031 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
TNorthover committed Aug 6, 2019
1 parent 81078de commit 1a112ed
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Target/AArch64/AArch64InstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,8 @@ bool AArch64InstructionSelector::earlySelect(MachineInstr &I) const {

Register DefReg = I.getOperand(0).getReg();
LLT Ty = MRI.getType(DefReg);
assert((Ty == LLT::scalar(64) || Ty == LLT::scalar(32)) &&
"Unexpected legal constant type");
if (Ty != LLT::scalar(64) && Ty != LLT::scalar(32))
return false;

if (Ty == LLT::scalar(64)) {
I.getOperand(1).ChangeToRegister(AArch64::XZR, false);
Expand Down
25 changes: 25 additions & 0 deletions test/CodeGen/AArch64/GlobalISel/const-0.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; RUN: llc -mtriple=aarch64-linux-gnu -global-isel -O0 -o - %s | FileCheck %s

%struct.comp = type { i8*, i32, i8*, [3 x i8], i32 }

define void @regbranch() {
; CHECK-LABEL: regbranch:
; CHECK: mov {{w[0-9]+}}, #0
cond_next240.i:
br i1 false, label %cond_true251.i, label %cond_next272.i

cond_true251.i:
switch i8 0, label %cond_next272.i [
i8 42, label %bb268.i
i8 43, label %bb268.i
i8 63, label %bb268.i
]

bb268.i:
br label %cond_next272.i

cond_next272.i:
%len.2.i = phi i32 [ 0, %bb268.i ], [ 0, %cond_next240.i ], [ 0, %cond_true251.i ]
%tmp278.i = icmp eq i32 %len.2.i, 1
ret void
}

0 comments on commit 1a112ed

Please sign in to comment.