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=i386-unknown-unknown -jump-is-expensive=0 | FileCheck %s --check-prefix=JUMP2
      3 ; RUN: llc < %s -mtriple=i386-unknown-unknown -jump-is-expensive=1 | FileCheck %s --check-prefix=JUMP1
      4 
      5 define void @foo(i32 %X, i32 %Y, i32 %Z) nounwind {
      6 ; JUMP2-LABEL: foo:
      7 ; JUMP2:       # %bb.0: # %entry
      8 ; JUMP2-NEXT:    cmpl $5, {{[0-9]+}}(%esp)
      9 ; JUMP2-NEXT:    jl .LBB0_3
     10 ; JUMP2-NEXT:  # %bb.1: # %entry
     11 ; JUMP2-NEXT:    movl {{[0-9]+}}(%esp), %eax
     12 ; JUMP2-NEXT:    testl %eax, %eax
     13 ; JUMP2-NEXT:    je .LBB0_3
     14 ; JUMP2-NEXT:  # %bb.2: # %UnifiedReturnBlock
     15 ; JUMP2-NEXT:    retl
     16 ; JUMP2-NEXT:  .LBB0_3: # %cond_true
     17 ; JUMP2-NEXT:    jmp bar # TAILCALL
     18 ;
     19 ; JUMP1-LABEL: foo:
     20 ; JUMP1:       # %bb.0: # %entry
     21 ; JUMP1-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
     22 ; JUMP1-NEXT:    setne %al
     23 ; JUMP1-NEXT:    cmpl $4, {{[0-9]+}}(%esp)
     24 ; JUMP1-NEXT:    setg %cl
     25 ; JUMP1-NEXT:    testb %al, %cl
     26 ; JUMP1-NEXT:    jne .LBB0_1
     27 ; JUMP1-NEXT:  # %bb.2: # %cond_true
     28 ; JUMP1-NEXT:    jmp bar # TAILCALL
     29 ; JUMP1-NEXT:  .LBB0_1: # %UnifiedReturnBlock
     30 ; JUMP1-NEXT:    retl
     31 entry:
     32   %tmp1 = icmp eq i32 %X, 0
     33   %tmp3 = icmp slt i32 %Y, 5
     34   %tmp4 = or i1 %tmp3, %tmp1
     35   br i1 %tmp4, label %cond_true, label %UnifiedReturnBlock
     36 
     37 cond_true:
     38   %tmp5 = tail call i32 (...) @bar( )
     39   ret void
     40 
     41 UnifiedReturnBlock:
     42   ret void
     43 }
     44 
     45 ; If the branch is unpredictable, don't add another branch
     46 ; regardless of whether they are expensive or not.
     47 
     48 define void @unpredictable(i32 %X, i32 %Y, i32 %Z) nounwind {
     49 ; JUMP2-LABEL: unpredictable:
     50 ; JUMP2:       # %bb.0: # %entry
     51 ; JUMP2-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
     52 ; JUMP2-NEXT:    setne %al
     53 ; JUMP2-NEXT:    cmpl $4, {{[0-9]+}}(%esp)
     54 ; JUMP2-NEXT:    setg %cl
     55 ; JUMP2-NEXT:    testb %al, %cl
     56 ; JUMP2-NEXT:    jne .LBB1_1
     57 ; JUMP2-NEXT:  # %bb.2: # %cond_true
     58 ; JUMP2-NEXT:    jmp bar # TAILCALL
     59 ; JUMP2-NEXT:  .LBB1_1: # %UnifiedReturnBlock
     60 ; JUMP2-NEXT:    retl
     61 ;
     62 ; JUMP1-LABEL: unpredictable:
     63 ; JUMP1:       # %bb.0: # %entry
     64 ; JUMP1-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
     65 ; JUMP1-NEXT:    setne %al
     66 ; JUMP1-NEXT:    cmpl $4, {{[0-9]+}}(%esp)
     67 ; JUMP1-NEXT:    setg %cl
     68 ; JUMP1-NEXT:    testb %al, %cl
     69 ; JUMP1-NEXT:    jne .LBB1_1
     70 ; JUMP1-NEXT:  # %bb.2: # %cond_true
     71 ; JUMP1-NEXT:    jmp bar # TAILCALL
     72 ; JUMP1-NEXT:  .LBB1_1: # %UnifiedReturnBlock
     73 ; JUMP1-NEXT:    retl
     74 entry:
     75   %tmp1 = icmp eq i32 %X, 0
     76   %tmp3 = icmp slt i32 %Y, 5
     77   %tmp4 = or i1 %tmp3, %tmp1
     78   br i1 %tmp4, label %cond_true, label %UnifiedReturnBlock, !unpredictable !0
     79 
     80 cond_true:
     81   %tmp5 = tail call i32 (...) @bar( )
     82   ret void
     83 
     84 UnifiedReturnBlock:
     85   ret void
     86 }
     87 
     88 declare i32 @bar(...)
     89 
     90 !0 = !{}
     91 
     92