blob: 54cc314fd85b3727934947b3ba40262db8af26f0 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc < %s -mtriple=sparcv9 -O2 -verify-machineinstrs | FileCheck %s
;; The branch-on-register condition here is undef (from the poison shift
;; amount), so ProcessImplicitDefs marks the BPR register operand as undef.
;; PHI elimination then splits a critical edge and rebuilds the branch via
;; analyzeBranch/insertBranch; the undef flag must survive that or the
;; machine verifier complains about reading a virtual register without a def
;; (and the register allocator crashes without the verifier).
;; https://github.com/llvm/llvm-project/issues/233111
define i64 @bpr_undef_reg() {
; CHECK-LABEL: bpr_undef_reg:
; CHECK: .cfi_startproc
; CHECK-NEXT: ! %bb.0: ! %entry
; CHECK-NEXT: cmp %g0, 0
; CHECK-NEXT: bne %icc, .LBB0_3
; CHECK-NEXT: mov -1, %o0
; CHECK-NEXT: ! %bb.1: ! %entry
; CHECK-NEXT: brz %o0, .LBB0_3
; CHECK-NEXT: nop
; CHECK-NEXT: ! %bb.2: ! %bb
; CHECK-NEXT: mov %o0, %o1
; CHECK-NEXT: mov %g0, %o0
; CHECK-NEXT: retl
; CHECK-NEXT: movrlz %o1, 0, %o0
; CHECK-NEXT: .LBB0_3:
; CHECK-NEXT: mov %g0, %o1
; CHECK-NEXT: retl
; CHECK-NEXT: movrlz %o1, 0, %o0
entry:
%sel = select i1 false, i64 0, i64 -1
%shr = lshr i64 0, poison
%cmp = icmp eq i64 %shr, 0
%or.cond = select i1 false, i1 true, i1 %cmp
br i1 %or.cond, label %exit, label %bb
bb:
br label %exit
exit:
%a = phi i64 [ %sel, %bb ], [ 0, %entry ]
%b = phi i64 [ 0, %bb ], [ -1, %entry ]
%neg = icmp slt i64 %a, 0
%res = select i1 %neg, i64 0, i64 %b
ret i64 %res
}