Fix a bunch of trivial cases of 'CHECK[^:]*$' in the tests. NFCI
[oota-llvm.git] / test / Transforms / InstSimplify / floating-point-compare.ll
1 ; RUN: opt < %s -instsimplify -S | FileCheck %s
2
3 ; These tests choose arbitrarily between float and double,
4 ; and between uge and olt, to give reasonble coverage 
5 ; without combinatorial explosion.
6
7 declare float @llvm.fabs.f32(float)
8 declare float @llvm.sqrt.f32(float)
9 declare double @llvm.powi.f64(double,i32)
10 declare float @llvm.exp.f32(float)
11 declare double @llvm.exp2.f64(double)
12 declare float @llvm.fma.f32(float,float,float)
13
14 declare void @expect_equal(i1,i1)
15
16 ; CHECK-LABEL: @orderedLessZeroTree(
17 define i1 @orderedLessZeroTree(float,float,float,float) {
18   %square = fmul float %0, %0
19   %abs = call float @llvm.fabs.f32(float %1)
20   %sqrt = call float @llvm.sqrt.f32(float %2)
21   %fma = call float @llvm.fma.f32(float %3, float %3, float %sqrt)
22   %div = fdiv float %square, %abs
23   %rem = frem float %sqrt, %fma
24   %add = fadd float %div, %rem
25   %uge = fcmp uge float %add, 0.000000e+00
26 ; CHECK: ret i1 true
27   ret i1 %uge
28 }
29
30 ; CHECK-LABEL: @orderedLessZeroExpExt(
31 define i1 @orderedLessZeroExpExt(float) {
32   %a = call float @llvm.exp.f32(float %0)
33   %b = fpext float %a to double
34   %uge = fcmp uge double %b, 0.000000e+00
35 ; CHECK: ret i1 true
36   ret i1 %uge
37 }
38
39 ; CHECK-LABEL: @orderedLessZeroExp2Trunc(
40 define i1 @orderedLessZeroExp2Trunc(double) {
41   %a = call double @llvm.exp2.f64(double %0)
42   %b = fptrunc double %a to float
43   %olt = fcmp olt float %b, 0.000000e+00
44 ; CHECK: ret i1 false
45   ret i1 %olt
46 }
47
48 ; CHECK-LABEL: @orderedLessZeroPowi(
49 define i1 @orderedLessZeroPowi(double,double) {
50   ; Even constant exponent
51   %a = call double @llvm.powi.f64(double %0, i32 2)
52   %square = fmul double %1, %1
53   ; Odd constant exponent with provably non-negative base
54   %b = call double @llvm.powi.f64(double %square, i32 3)
55   %c = fadd double %a, %b
56   %olt = fcmp olt double %b, 0.000000e+00
57 ; CHECK: ret i1 false
58   ret i1 %olt
59 }
60
61 define i1 @nonans1(double %in1, double %in2) {
62   %cmp = fcmp nnan uno double %in1, %in2
63   ret i1 %cmp
64
65 ; CHECK-LABEL: @nonans1
66 ; CHECK-NEXT: ret i1 false
67 }
68
69 define i1 @nonans2(double %in1, double %in2) {
70   %cmp = fcmp nnan ord double %in1, %in2
71   ret i1 %cmp
72
73 ; CHECK-LABEL: @nonans2
74 ; CHECK-NEXT: ret i1 true
75 }