Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=LNX
      3 ; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s --check-prefix=WIN
      4 
      5 ; Reuse the flags value from the add instructions instead of emitting separate
      6 ; testl instructions.
      7 
      8 ; Use the flags on the add.
      9 
     10 define i32 @test1(i32* %x, i32 %y, i32 %a, i32 %b) nounwind {
     11 ; LNX-LABEL: test1:
     12 ; LNX:       # %bb.0:
     13 ; LNX-NEXT:    addl (%rdi), %esi
     14 ; LNX-NEXT:    cmovnsl %ecx, %edx
     15 ; LNX-NEXT:    movl %edx, %eax
     16 ; LNX-NEXT:    retq
     17 ;
     18 ; WIN-LABEL: test1:
     19 ; WIN:       # %bb.0:
     20 ; WIN-NEXT:    addl (%rcx), %edx
     21 ; WIN-NEXT:    cmovnsl %r9d, %r8d
     22 ; WIN-NEXT:    movl %r8d, %eax
     23 ; WIN-NEXT:    retq
     24 	%tmp2 = load i32, i32* %x, align 4		; <i32> [#uses=1]
     25 	%tmp4 = add i32 %tmp2, %y		; <i32> [#uses=1]
     26 	%tmp5 = icmp slt i32 %tmp4, 0		; <i1> [#uses=1]
     27 	%tmp.0 = select i1 %tmp5, i32 %a, i32 %b		; <i32> [#uses=1]
     28 	ret i32 %tmp.0
     29 }
     30 
     31 declare void @foo(i32)
     32 
     33 ; Don't use the flags result of the and here, since the and has no
     34 ; other use. A simple test is better.
     35 
     36 define void @test2(i32 %x) nounwind {
     37 ; LNX-LABEL: test2:
     38 ; LNX:       # %bb.0:
     39 ; LNX-NEXT:    testb $16, %dil
     40 ; LNX-NEXT:    jne .LBB1_2
     41 ; LNX-NEXT:  # %bb.1: # %true
     42 ; LNX-NEXT:    pushq %rax
     43 ; LNX-NEXT:    callq foo
     44 ; LNX-NEXT:    popq %rax
     45 ; LNX-NEXT:  .LBB1_2: # %false
     46 ; LNX-NEXT:    retq
     47 ;
     48 ; WIN-LABEL: test2:
     49 ; WIN:       # %bb.0:
     50 ; WIN-NEXT:    subq $40, %rsp
     51 ; WIN-NEXT:    testb $16, %cl
     52 ; WIN-NEXT:    jne .LBB1_2
     53 ; WIN-NEXT:  # %bb.1: # %true
     54 ; WIN-NEXT:    callq foo
     55 ; WIN-NEXT:  .LBB1_2: # %false
     56 ; WIN-NEXT:    addq $40, %rsp
     57 ; WIN-NEXT:    retq
     58   %y = and i32 %x, 16
     59   %t = icmp eq i32 %y, 0
     60   br i1 %t, label %true, label %false
     61 true:
     62   call void @foo(i32 %x)
     63   ret void
     64 false:
     65   ret void
     66 }
     67 
     68 ; Do use the flags result of the and here, since the and has another use.
     69 
     70 define void @test3(i32 %x) nounwind {
     71 ; LNX-LABEL: test3:
     72 ; LNX:       # %bb.0:
     73 ; LNX-NEXT:    andl $16, %edi
     74 ; LNX-NEXT:    jne .LBB2_2
     75 ; LNX-NEXT:  # %bb.1: # %true
     76 ; LNX-NEXT:    pushq %rax
     77 ; LNX-NEXT:    callq foo
     78 ; LNX-NEXT:    popq %rax
     79 ; LNX-NEXT:  .LBB2_2: # %false
     80 ; LNX-NEXT:    retq
     81 ;
     82 ; WIN-LABEL: test3:
     83 ; WIN:       # %bb.0:
     84 ; WIN-NEXT:    subq $40, %rsp
     85 ; WIN-NEXT:    andl $16, %ecx
     86 ; WIN-NEXT:    jne .LBB2_2
     87 ; WIN-NEXT:  # %bb.1: # %true
     88 ; WIN-NEXT:    callq foo
     89 ; WIN-NEXT:  .LBB2_2: # %false
     90 ; WIN-NEXT:    addq $40, %rsp
     91 ; WIN-NEXT:    retq
     92   %y = and i32 %x, 16
     93   %t = icmp eq i32 %y, 0
     94   br i1 %t, label %true, label %false
     95 true:
     96   call void @foo(i32 %y)
     97   ret void
     98 false:
     99   ret void
    100 }
    101 
    102