Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl --show-mc-encoding | FileCheck %s
      2 
      3 ; CHECK-LABEL: test1
      4 ; CHECK: vucomisd {{.*}}encoding: [0x62
      5 define double @test1(double %a, double %b) nounwind {
      6   %tobool = fcmp une double %a, %b
      7   br i1 %tobool, label %l1, label %l2
      8 
      9 l1:
     10   %c = fsub double %a, %b
     11   ret double %c
     12 l2:
     13   %c1 = fadd double %a, %b
     14   ret double %c1
     15 }
     16 
     17 ; CHECK-LABEL: test2
     18 ; CHECK: vucomiss {{.*}}encoding: [0x62
     19 define float @test2(float %a, float %b) nounwind {
     20   %tobool = fcmp olt float %a, %b
     21   br i1 %tobool, label %l1, label %l2
     22 
     23 l1:
     24   %c = fsub float %a, %b
     25   ret float %c
     26 l2:
     27   %c1 = fadd float %a, %b
     28   ret float %c1
     29 }
     30 
     31 ; FIXME: Can use vcmpeqss and extract from the mask here in AVX512.
     32 ; CHECK-LABEL: test3
     33 ; CHECK: vucomiss {{.*}}encoding: [0x62
     34 define i32 @test3(float %a, float %b) {
     35 
     36   %cmp10.i = fcmp oeq float %a, %b
     37   %conv11.i = zext i1 %cmp10.i to i32
     38   ret i32 %conv11.i
     39 }
     40 
     41 ; CHECK-LABEL: test5
     42 ; CHECK: ret
     43 define float @test5(float %p) #0 {
     44 entry:
     45   %cmp = fcmp oeq float %p, 0.000000e+00
     46   br i1 %cmp, label %return, label %if.end
     47 
     48 if.end:                                           ; preds = %entry
     49   %cmp1 = fcmp ogt float %p, 0.000000e+00
     50   %cond = select i1 %cmp1, float 1.000000e+00, float -1.000000e+00
     51   br label %return
     52 
     53 return:                                           ; preds = %if.end, %entry
     54   %retval.0 = phi float [ %cond, %if.end ], [ %p, %entry ]
     55   ret float %retval.0
     56 }
     57 
     58 ; CHECK-LABEL: test6
     59 ; CHECK: cmpl
     60 ; CHECK-NOT: kmov
     61 ; CHECK: ret
     62 define i32 @test6(i32 %a, i32 %b) {
     63   %cmp = icmp eq i32 %a, %b
     64   %res = zext i1 %cmp to i32
     65   ret i32 %res
     66 }
     67 
     68 ; CHECK-LABEL: test7
     69 ; CHECK: vucomisd
     70 ; CHECK-NOT: kmov
     71 ; CHECK: ret
     72 define i32 @test7(double %x, double %y) #2 {
     73 entry:
     74   %0 = fcmp one double %x, %y
     75   %or = zext i1 %0 to i32
     76   ret i32 %or
     77 }
     78 
     79 define i32 @test8(i32 %a1, i32 %a2, i32 %a3) {
     80   %tmp1 = icmp eq i32 %a1, -1
     81   %tmp2 = icmp eq i32 %a2, -2147483648
     82   %tmp3 = and i1 %tmp1, %tmp2
     83   %tmp4 = icmp eq i32 %a3, 0
     84   %tmp5 = or i1 %tmp3, %tmp4
     85   %res = select i1 %tmp5, i32 1, i32 %a3
     86   ret i32 %res
     87 }
     88 
     89 ; CHECK-LABEL: test9
     90 ; CHECK: testb
     91 ; CHECK-NOT: kmov
     92 ; CHECK: ret
     93 define i32 @test9(i64 %a) {
     94  %b = and i64 %a, 1
     95  %cmp10.i = icmp eq i64 %b, 0
     96  br i1 %cmp10.i, label %A, label %B
     97 A:
     98  ret i32 6
     99 B:
    100  ret i32 7
    101 }
    102