1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -verify-machineinstrs -o - %s | FileCheck %s 3target triple = "arm64--" 4 5; AArch64InstrInfo::optimizeCondBranch() optimizes the 6; "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 already 10; formed in SelectionDAG, optimizeCondBranch() only triggers if the and 11; 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 // =0x1 17; CHECK-NEXT: cbnz w8, .LBB0_3 18; CHECK-NEXT: // %bb.1: // %b1 19; CHECK-NEXT: cbz wzr, .LBB0_4 20; CHECK-NEXT: // %bb.2: // %b3 21; CHECK-NEXT: ldr w8, [x8] 22; CHECK-NEXT: and w0, w8, #0x100 23; CHECK-NEXT: cbz w0, .LBB0_5 24; CHECK-NEXT: .LBB0_3: // %common.ret.sink.split 25; CHECK-NEXT: b extfunc 26; CHECK-NEXT: .LBB0_4: // %b2 27; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill 28; CHECK-NEXT: .cfi_def_cfa_offset 16 29; CHECK-NEXT: .cfi_offset w30, -16 30; CHECK-NEXT: bl extfunc 31; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload 32; CHECK-NEXT: .cfi_def_cfa_offset 0 33; CHECK-NEXT: .cfi_restore w30 34; CHECK-NEXT: cbnz w0, .LBB0_3 35; CHECK-NEXT: .LBB0_5: // %common.ret 36; CHECK-NEXT: ret 37 %c0 = icmp sgt i64 0, 0 38 br i1 %c0, label %b1, label %b6 39 40b1: 41 br i1 undef, label %b3, label %b2 42 43b2: 44 %v0 = tail call i32 @extfunc() 45 br label %b5 46 47b3: 48 %v1 = load i32, ptr undef, align 4 49 %v2 = and i32 %v1, 256 50 br label %b5 51 52b5: 53 %v3 = phi i32 [ %v2, %b3 ], [ %v0, %b2 ] 54 %c1 = icmp eq i32 %v3, 0 55 br i1 %c1, label %b8, label %b7 56 57b6: 58 tail call i32 @extfunc() 59 ret void 60 61b7: 62 tail call i32 @extfunc() 63 ret void 64 65b8: 66 ret void 67} 68 69declare i32 @extfunc() 70