1 ; NOTE: Assertions have been autogenerated by update_test_checks.py 2 ; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4 ; These tests choose arbitrarily between float and double, 5 ; and between uge and olt, to give reasonble coverage 6 ; without combinatorial explosion. 7 8 declare float @llvm.fabs.f32(float) 9 declare float @llvm.sqrt.f32(float) 10 declare double @llvm.powi.f64(double,i32) 11 declare float @llvm.exp.f32(float) 12 declare float @llvm.minnum.f32(float, float) 13 declare float @llvm.maxnum.f32(float, float) 14 declare double @llvm.exp2.f64(double) 15 declare float @llvm.fma.f32(float,float,float) 16 17 declare void @expect_equal(i1,i1) 18 19 define i1 @orderedLessZeroTree(float,float,float,float) { 20 ; CHECK-LABEL: @orderedLessZeroTree( 21 ; CHECK: ret i1 true 22 ; 23 %square = fmul float %0, %0 24 %abs = call float @llvm.fabs.f32(float %1) 25 %sqrt = call float @llvm.sqrt.f32(float %2) 26 %fma = call float @llvm.fma.f32(float %3, float %3, float %sqrt) 27 %div = fdiv float %square, %abs 28 %rem = frem float %sqrt, %fma 29 %add = fadd float %div, %rem 30 %uge = fcmp uge float %add, 0.000000e+00 31 ret i1 %uge 32 } 33 34 define i1 @orderedLessZeroExpExt(float) { 35 ; CHECK-LABEL: @orderedLessZeroExpExt( 36 ; CHECK: ret i1 true 37 ; 38 %a = call float @llvm.exp.f32(float %0) 39 %b = fpext float %a to double 40 %uge = fcmp uge double %b, 0.000000e+00 41 ret i1 %uge 42 } 43 44 define i1 @orderedLessZeroExp2Trunc(double) { 45 ; CHECK-LABEL: @orderedLessZeroExp2Trunc( 46 ; CHECK: ret i1 false 47 ; 48 %a = call double @llvm.exp2.f64(double %0) 49 %b = fptrunc double %a to float 50 %olt = fcmp olt float %b, 0.000000e+00 51 ret i1 %olt 52 } 53 54 define i1 @orderedLessZeroPowi(double,double) { 55 ; CHECK-LABEL: @orderedLessZeroPowi( 56 ; CHECK: ret i1 false 57 ; 58 ; Even constant exponent 59 %a = call double @llvm.powi.f64(double %0, i32 2) 60 %square = fmul double %1, %1 61 ; Odd constant exponent with provably non-negative base 62 %b = call double @llvm.powi.f64(double %square, i32 3) 63 %c = fadd double %a, %b 64 %olt = fcmp olt double %b, 0.000000e+00 65 ret i1 %olt 66 } 67 68 define i1 @orderedLessZeroUIToFP(i32) { 69 ; CHECK-LABEL: @orderedLessZeroUIToFP( 70 ; CHECK: ret i1 true 71 ; 72 %a = uitofp i32 %0 to float 73 %uge = fcmp uge float %a, 0.000000e+00 74 ret i1 %uge 75 } 76 77 define i1 @orderedLessZeroSelect(float, float) { 78 ; CHECK-LABEL: @orderedLessZeroSelect( 79 ; CHECK: ret i1 true 80 ; 81 %a = call float @llvm.exp.f32(float %0) 82 %b = call float @llvm.fabs.f32(float %1) 83 %c = fcmp olt float %0, %1 84 %d = select i1 %c, float %a, float %b 85 %e = fadd float %d, 1.0 86 %uge = fcmp uge float %e, 0.000000e+00 87 ret i1 %uge 88 } 89 90 define i1 @orderedLessZeroMinNum(float, float) { 91 ; CHECK-LABEL: @orderedLessZeroMinNum( 92 ; CHECK: ret i1 true 93 ; 94 %a = call float @llvm.exp.f32(float %0) 95 %b = call float @llvm.fabs.f32(float %1) 96 %c = call float @llvm.minnum.f32(float %a, float %b) 97 %uge = fcmp uge float %c, 0.000000e+00 98 ret i1 %uge 99 } 100 101 define i1 @orderedLessZeroMaxNum(float, float) { 102 ; CHECK-LABEL: @orderedLessZeroMaxNum( 103 ; CHECK: ret i1 true 104 ; 105 %a = call float @llvm.exp.f32(float %0) 106 %b = call float @llvm.maxnum.f32(float %a, float %1) 107 %uge = fcmp uge float %b, 0.000000e+00 108 ret i1 %uge 109 } 110 111 define i1 @nonans1(double %in1, double %in2) { 112 ; CHECK-LABEL: @nonans1( 113 ; CHECK: ret i1 false 114 ; 115 %cmp = fcmp nnan uno double %in1, %in2 116 ret i1 %cmp 117 } 118 119 define i1 @nonans2(double %in1, double %in2) { 120 ; CHECK-LABEL: @nonans2( 121 ; CHECK: ret i1 true 122 ; 123 %cmp = fcmp nnan ord double %in1, %in2 124 ret i1 %cmp 125 } 126