Compiler projects using llvm
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64--                          | FileCheck %s --check-prefixes=CHECK
; RUN: llc < %s -mtriple=x86_64-- -mattr=+sbb-dep-breaking | FileCheck %s --check-prefixes=IDIOM

%struct.y_s = type { ptr, ptr }

define i32 @mallocbench_gs(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) nounwind {
; CHECK-LABEL: mallocbench_gs:
; CHECK:       # %bb.0:
; CHECK-NEXT:    pushq %rbp
; CHECK-NEXT:    pushq %r15
; CHECK-NEXT:    pushq %r14
; CHECK-NEXT:    pushq %r13
; CHECK-NEXT:    pushq %r12
; CHECK-NEXT:    pushq %rbx
; CHECK-NEXT:    pushq %rax
; CHECK-NEXT:    movl %r8d, %r13d
; CHECK-NEXT:    movl %ecx, %r14d
; CHECK-NEXT:    movl %edx, %r15d
; CHECK-NEXT:    movq %rsi, %rbx
; CHECK-NEXT:    movq %rdi, %r12
; CHECK-NEXT:    movq (%rsi), %rdi
; CHECK-NEXT:    movq 8(%rsi), %rsi
; CHECK-NEXT:    movq %rbx, %rdx
; CHECK-NEXT:    callq foo1@PLT
; CHECK-NEXT:    movq 8(%rbx), %rax
; CHECK-NEXT:    movq (%rax), %rdx
; CHECK-NEXT:    xorl %ebp, %ebp
; CHECK-NEXT:    movl %r13d, %ecx
; CHECK-NEXT:    negl %ecx
; CHECK-NEXT:    movl $0, %eax
; CHECK-NEXT:    sbbq %rax, %rax
; CHECK-NEXT:    orq %rdx, %rax
; CHECK-NEXT:    cmpl $1, %r13d
; CHECK-NEXT:    sbbq %rbp, %rbp
; CHECK-NEXT:    orq %rdx, %rbp
; CHECK-NEXT:    subq $8, %rsp
; CHECK-NEXT:    movq %r12, %rdi
; CHECK-NEXT:    movl %r15d, %esi
; CHECK-NEXT:    movl %r14d, %edx
; CHECK-NEXT:    xorl %ecx, %ecx
; CHECK-NEXT:    xorl %r8d, %r8d
; CHECK-NEXT:    xorl %r9d, %r9d
; CHECK-NEXT:    pushq %rbp
; CHECK-NEXT:    pushq %rax
; CHECK-NEXT:    pushq %rbx
; CHECK-NEXT:    callq foo2@PLT
; CHECK-NEXT:    addq $40, %rsp
; CHECK-NEXT:    popq %rbx
; CHECK-NEXT:    popq %r12
; CHECK-NEXT:    popq %r13
; CHECK-NEXT:    popq %r14
; CHECK-NEXT:    popq %r15
; CHECK-NEXT:    popq %rbp
; CHECK-NEXT:    retq
;
; IDIOM-LABEL: mallocbench_gs:
; IDIOM:       # %bb.0:
; IDIOM-NEXT:    pushq %rbp
; IDIOM-NEXT:    pushq %r15
; IDIOM-NEXT:    pushq %r14
; IDIOM-NEXT:    pushq %r13
; IDIOM-NEXT:    pushq %r12
; IDIOM-NEXT:    pushq %rbx
; IDIOM-NEXT:    pushq %rax
; IDIOM-NEXT:    movl %r8d, %r13d
; IDIOM-NEXT:    movl %ecx, %r14d
; IDIOM-NEXT:    movl %edx, %r15d
; IDIOM-NEXT:    movq %rsi, %rbx
; IDIOM-NEXT:    movq %rdi, %r12
; IDIOM-NEXT:    movq (%rsi), %rdi
; IDIOM-NEXT:    movq 8(%rsi), %rsi
; IDIOM-NEXT:    movq %rbx, %rdx
; IDIOM-NEXT:    callq foo1@PLT
; IDIOM-NEXT:    movq 8(%rbx), %rax
; IDIOM-NEXT:    movq (%rax), %rdx
; IDIOM-NEXT:    movl %r13d, %ecx
; IDIOM-NEXT:    negl %ecx
; IDIOM-NEXT:    sbbq %rbp, %rbp
; IDIOM-NEXT:    orq %rdx, %rbp
; IDIOM-NEXT:    cmpl $1, %r13d
; IDIOM-NEXT:    sbbq %rax, %rax
; IDIOM-NEXT:    orq %rdx, %rax
; IDIOM-NEXT:    subq $8, %rsp
; IDIOM-NEXT:    movq %r12, %rdi
; IDIOM-NEXT:    movl %r15d, %esi
; IDIOM-NEXT:    movl %r14d, %edx
; IDIOM-NEXT:    xorl %ecx, %ecx
; IDIOM-NEXT:    xorl %r8d, %r8d
; IDIOM-NEXT:    xorl %r9d, %r9d
; IDIOM-NEXT:    pushq %rax
; IDIOM-NEXT:    pushq %rbp
; IDIOM-NEXT:    pushq %rbx
; IDIOM-NEXT:    callq foo2@PLT
; IDIOM-NEXT:    addq $40, %rsp
; IDIOM-NEXT:    popq %rbx
; IDIOM-NEXT:    popq %r12
; IDIOM-NEXT:    popq %r13
; IDIOM-NEXT:    popq %r14
; IDIOM-NEXT:    popq %r15
; IDIOM-NEXT:    popq %rbp
; IDIOM-NEXT:    retq
  %6 = load ptr, ptr %1, align 8
  %7 = getelementptr inbounds %struct.y_s, ptr %1, i64 0, i32 1
  %8 = load ptr, ptr %7, align 8
  tail call void @foo1(ptr noundef %6, ptr noundef %8, ptr noundef %1)
  %9 = icmp eq i32 %4, 0
  %10 = load ptr, ptr %7, align 8
  %11 = load i64, ptr %10, align 8
  %12 = select i1 %9, i64 %11, i64 -1
  %13 = select i1 %9, i64 -1, i64 %11
  %14 = tail call noundef i32 @foo2(ptr noundef %0, i32 noundef %2, i32 noundef %3, i32 noundef 0, i32 noundef 0, i32 noundef 0, ptr noundef nonnull %1, i64 noundef %12, i64 noundef %13)
  ret i32 %14
}

declare void @foo1(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1
declare noundef i32 @foo2(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1