1 ; RUN: opt -S -instcombine < %s | FileCheck %s 2 3 define i1 @test1(float %x, float %y) nounwind { 4 %ext1 = fpext float %x to double 5 %ext2 = fpext float %y to double 6 %cmp = fcmp ogt double %ext1, %ext2 7 ret i1 %cmp 8 ; CHECK-LABEL: @test1( 9 ; CHECK-NEXT: fcmp ogt float %x, %y 10 } 11 12 define i1 @test2(float %a) nounwind { 13 %ext = fpext float %a to double 14 %cmp = fcmp ogt double %ext, 1.000000e+00 15 ret i1 %cmp 16 ; CHECK-LABEL: @test2( 17 ; CHECK-NEXT: fcmp ogt float %a, 1.0 18 } 19 20 define i1 @test3(float %a) nounwind { 21 %ext = fpext float %a to double 22 %cmp = fcmp ogt double %ext, 0x3FF0000000000001 ; more precision than float. 23 ret i1 %cmp 24 ; CHECK-LABEL: @test3( 25 ; CHECK-NEXT: fpext float %a to double 26 } 27 28 define i1 @test4(float %a) nounwind { 29 %ext = fpext float %a to double 30 %cmp = fcmp ogt double %ext, 0x36A0000000000000 ; denormal in float. 31 ret i1 %cmp 32 ; CHECK-LABEL: @test4( 33 ; CHECK-NEXT: fpext float %a to double 34 } 35 36 define i1 @test5(float %a) nounwind { 37 %neg = fsub float -0.000000e+00, %a 38 %cmp = fcmp ogt float %neg, 1.000000e+00 39 ret i1 %cmp 40 ; CHECK-LABEL: @test5( 41 ; CHECK-NEXT: fcmp olt float %a, -1.0 42 } 43 44 define i1 @test6(float %x, float %y) nounwind { 45 %neg1 = fsub float -0.000000e+00, %x 46 %neg2 = fsub float -0.000000e+00, %y 47 %cmp = fcmp olt float %neg1, %neg2 48 ret i1 %cmp 49 ; CHECK-LABEL: @test6( 50 ; CHECK-NEXT: fcmp ogt float %x, %y 51 } 52 53 define i1 @test7(float %x) nounwind readnone ssp noredzone { 54 %ext = fpext float %x to ppc_fp128 55 %cmp = fcmp ogt ppc_fp128 %ext, 0xM00000000000000000000000000000000 56 ret i1 %cmp 57 ; CHECK-LABEL: @test7( 58 ; CHECK-NEXT: fcmp ogt float %x, 0.000000e+00 59 } 60 61 define float @test8(float %x) nounwind readnone optsize ssp { 62 %conv = fpext float %x to double 63 %cmp = fcmp olt double %conv, 0.000000e+00 64 %conv1 = zext i1 %cmp to i32 65 %conv2 = sitofp i32 %conv1 to float 66 ret float %conv2 67 ; Float comparison to zero shouldn't cast to double. 68 ; CHECK-LABEL: @test8( 69 ; CHECK-NEXT: fcmp olt float %x, 0.000000e+00 70 } 71 72 declare double @fabs(double) nounwind readnone 73 74 define i32 @test9(double %a) nounwind { 75 %call = tail call double @fabs(double %a) nounwind 76 %cmp = fcmp olt double %call, 0.000000e+00 77 %conv = zext i1 %cmp to i32 78 ret i32 %conv 79 ; CHECK-LABEL: @test9( 80 ; CHECK-NOT: fabs 81 ; CHECK: ret i32 0 82 } 83 84 define i32 @test10(double %a) nounwind { 85 %call = tail call double @fabs(double %a) nounwind 86 %cmp = fcmp ole double %call, 0.000000e+00 87 %conv = zext i1 %cmp to i32 88 ret i32 %conv 89 ; CHECK-LABEL: @test10( 90 ; CHECK-NOT: fabs 91 ; CHECK: fcmp oeq double %a, 0.000000e+00 92 } 93 94 define i32 @test11(double %a) nounwind { 95 %call = tail call double @fabs(double %a) nounwind 96 %cmp = fcmp ogt double %call, 0.000000e+00 97 %conv = zext i1 %cmp to i32 98 ret i32 %conv 99 ; CHECK-LABEL: @test11( 100 ; CHECK-NOT: fabs 101 ; CHECK: fcmp one double %a, 0.000000e+00 102 } 103 104 define i32 @test12(double %a) nounwind { 105 %call = tail call double @fabs(double %a) nounwind 106 %cmp = fcmp oge double %call, 0.000000e+00 107 %conv = zext i1 %cmp to i32 108 ret i32 %conv 109 ; CHECK-LABEL: @test12( 110 ; CHECK-NOT: fabs 111 ; CHECK: fcmp ord double %a, 0.000000e+00 112 } 113 114 define i32 @test13(double %a) nounwind { 115 %call = tail call double @fabs(double %a) nounwind 116 %cmp = fcmp une double %call, 0.000000e+00 117 %conv = zext i1 %cmp to i32 118 ret i32 %conv 119 ; CHECK-LABEL: @test13( 120 ; CHECK-NOT: fabs 121 ; CHECK: fcmp une double %a, 0.000000e+00 122 } 123 124 define i32 @test14(double %a) nounwind { 125 %call = tail call double @fabs(double %a) nounwind 126 %cmp = fcmp oeq double %call, 0.000000e+00 127 %conv = zext i1 %cmp to i32 128 ret i32 %conv 129 ; CHECK-LABEL: @test14( 130 ; CHECK-NOT: fabs 131 ; CHECK: fcmp oeq double %a, 0.000000e+00 132 } 133 134 define i32 @test15(double %a) nounwind { 135 %call = tail call double @fabs(double %a) nounwind 136 %cmp = fcmp one double %call, 0.000000e+00 137 %conv = zext i1 %cmp to i32 138 ret i32 %conv 139 ; CHECK-LABEL: @test15( 140 ; CHECK-NOT: fabs 141 ; CHECK: fcmp one double %a, 0.000000e+00 142 } 143 144 define i32 @test16(double %a) nounwind { 145 %call = tail call double @fabs(double %a) nounwind 146 %cmp = fcmp ueq double %call, 0.000000e+00 147 %conv = zext i1 %cmp to i32 148 ret i32 %conv 149 ; CHECK-LABEL: @test16( 150 ; CHECK-NOT: fabs 151 ; CHECK: fcmp ueq double %a, 0.000000e+00 152 } 153 154 ; Don't crash. 155 define i32 @test17(double %a, double (double)* %p) nounwind { 156 %call = tail call double %p(double %a) nounwind 157 %cmp = fcmp ueq double %call, 0.000000e+00 158 %conv = zext i1 %cmp to i32 159 ret i32 %conv 160 } 161