; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
; RUN: -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
; RUN: -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
; RUN: -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-AIX
; Function Attrs: nounwind uwtable
define dso_local signext i32 @main() local_unnamed_addr {
; CHECK-LABEL: main:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: li 3, -1
; CHECK-NEXT: li 4, 0
; CHECK-NEXT: std 3, -8(1)
; CHECK-NEXT: addi 3, 1, -8
; CHECK-NEXT: .p2align 4
; CHECK-NEXT: .LBB0_1: # %do.body
; CHECK-NEXT: #
; CHECK-NEXT: #APP
; CHECK-NEXT: ldarx 5, 0, 3
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: stdcx. 4, 0, 3
; CHECK-NEXT: bne 0, .LBB0_1
; CHECK-NEXT: # %bb.2: # %do.end
; CHECK-NEXT: ld 3, -8(1)
; CHECK-NEXT: li 4, 55
; CHECK-NEXT: cmpldi 3, 0
; CHECK-NEXT: li 3, 66
; CHECK-NEXT: iseleq 3, 4, 3
; CHECK-NEXT: blr
;
; CHECK-AIX-LABEL: main:
; CHECK-AIX: # %bb.0: # %entry
; CHECK-AIX-NEXT: li 3, -1
; CHECK-AIX-NEXT: li 4, 0
; CHECK-AIX-NEXT: std 3, -8(1)
; CHECK-AIX-NEXT: addi 3, 1, -8
; CHECK-AIX-NEXT: .align 4
; CHECK-AIX-NEXT: L..BB0_1: # %do.body
; CHECK-AIX-NEXT: #
; CHECK-AIX-NEXT: #APP
; CHECK-AIX-NEXT: ldarx 5, 0, 3
; CHECK-AIX-NEXT: #NO_APP
; CHECK-AIX-NEXT: stdcx. 4, 0, 3
; CHECK-AIX-NEXT: bne 0, L..BB0_1
; CHECK-AIX-NEXT: # %bb.2: # %do.end
; CHECK-AIX-NEXT: ld 3, -8(1)
; CHECK-AIX-NEXT: li 4, 55
; CHECK-AIX-NEXT: cmpldi 3, 0
; CHECK-AIX-NEXT: li 3, 66
; CHECK-AIX-NEXT: iseleq 3, 4, 3
; CHECK-AIX-NEXT: blr
entry:
%x64 = alloca i64, align 8
call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %x64)
store i64 -1, ptr %x64, align 8
br label %do.body
do.body: ; preds = %do.body, %entry
%0 = call i64 asm sideeffect "ldarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i64) nonnull %x64)
%1 = call i32 @llvm.ppc.stdcx(ptr nonnull %x64, i64 0)
%tobool.not = icmp eq i32 %1, 0
br i1 %tobool.not, label %do.body, label %do.end
do.end: ; preds = %do.body
%2 = load i64, ptr %x64, align 8
%cmp = icmp eq i64 %2, 0
%. = select i1 %cmp, i32 55, i32 66
call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %x64)
ret i32 %.
}
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
; Function Attrs: nounwind writeonly
declare i32 @llvm.ppc.stdcx(ptr, i64)
; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)