70 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -verify-machineinstrs -o - %s | FileCheck %s3target triple = "arm64--"4 5; AArch64InstrInfo::optimizeCondBranch() optimizes the6; "x = and y, 256; cmp x, 0; br" from an "and; cbnz" to a tbnz instruction.7; It forgot to clear the a flag resulting in a MachineVerifier complaint.8;9; Writing a stable/simple test is tricky since most tbz instructions are already10; formed in SelectionDAG, optimizeCondBranch() only triggers if the and11; instruction is in a different block than the conditional jump.12 13define void @func() uwtable {14; CHECK-LABEL: func:15; CHECK: // %bb.0:16; CHECK-NEXT: mov w8, #1 // =0x117; CHECK-NEXT: cbnz w8, .LBB0_318; CHECK-NEXT: // %bb.1: // %b119; CHECK-NEXT: cbz w8, .LBB0_420; CHECK-NEXT: // %bb.2: // %b321; CHECK-NEXT: ldr w8, [x8]22; CHECK-NEXT: and w0, w8, #0x10023; CHECK-NEXT: cbz w0, .LBB0_524; CHECK-NEXT: .LBB0_3: // %common.ret.sink.split25; CHECK-NEXT: b extfunc26; CHECK-NEXT: .LBB0_4: // %b227; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill28; CHECK-NEXT: .cfi_def_cfa_offset 1629; CHECK-NEXT: .cfi_offset w30, -1630; CHECK-NEXT: bl extfunc31; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload32; CHECK-NEXT: .cfi_def_cfa_offset 033; CHECK-NEXT: .cfi_restore w3034; CHECK-NEXT: cbnz w0, .LBB0_335; CHECK-NEXT: .LBB0_5: // %common.ret36; CHECK-NEXT: ret37 %c0 = icmp sgt i64 0, 038 br i1 %c0, label %b1, label %b639 40b1:41 br i1 poison, label %b3, label %b242 43b2:44 %v0 = tail call i32 @extfunc()45 br label %b546 47b3:48 %v1 = load i32, ptr undef, align 449 %v2 = and i32 %v1, 25650 br label %b551 52b5:53 %v3 = phi i32 [ %v2, %b3 ], [ %v0, %b2 ]54 %c1 = icmp eq i32 %v3, 055 br i1 %c1, label %b8, label %b756 57b6:58 tail call i32 @extfunc()59 ret void60 61b7:62 tail call i32 @extfunc()63 ret void64 65b8:66 ret void67}68 69declare i32 @extfunc()70