1; RUN: opt -S -instcombine < %s | FileCheck %s 2target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 3target triple = "x86_64-apple-macosx10.8.0" 4 5define i32 @test1(float %x, float %y) nounwind uwtable { 6 %1 = fpext float %x to double 7 %2 = call double @ceil(double %1) nounwind readnone 8 %3 = fpext float %y to double 9 %4 = fcmp oeq double %2, %3 10 %5 = zext i1 %4 to i32 11 ret i32 %5 12; CHECK-LABEL: @test1( 13; CHECK-NEXT: %ceilf = call float @ceilf(float %x) 14; CHECK-NEXT: fcmp oeq float %ceilf, %y 15} 16 17define i32 @test2(float %x, float %y) nounwind uwtable { 18 %1 = fpext float %x to double 19 %2 = call double @fabs(double %1) nounwind readnone 20 %3 = fpext float %y to double 21 %4 = fcmp oeq double %2, %3 22 %5 = zext i1 %4 to i32 23 ret i32 %5 24; CHECK-LABEL: @test2( 25; CHECK-NEXT: %fabsf = call float @fabsf(float %x) 26; CHECK-NEXT: fcmp oeq float %fabsf, %y 27} 28 29define i32 @test3(float %x, float %y) nounwind uwtable { 30 %1 = fpext float %x to double 31 %2 = call double @floor(double %1) nounwind readnone 32 %3 = fpext float %y to double 33 %4 = fcmp oeq double %2, %3 34 %5 = zext i1 %4 to i32 35 ret i32 %5 36; CHECK-LABEL: @test3( 37; CHECK-NEXT: %floorf = call float @floorf(float %x) 38; CHECK-NEXT: fcmp oeq float %floorf, %y 39} 40 41define i32 @test4(float %x, float %y) nounwind uwtable { 42 %1 = fpext float %x to double 43 %2 = call double @nearbyint(double %1) nounwind 44 %3 = fpext float %y to double 45 %4 = fcmp oeq double %2, %3 46 %5 = zext i1 %4 to i32 47 ret i32 %5 48; CHECK-LABEL: @test4( 49; CHECK-NEXT: %nearbyintf = call float @nearbyintf(float %x) 50; CHECK-NEXT: fcmp oeq float %nearbyintf, %y 51} 52 53define i32 @test5(float %x, float %y) nounwind uwtable { 54 %1 = fpext float %x to double 55 %2 = call double @rint(double %1) nounwind 56 %3 = fpext float %y to double 57 %4 = fcmp oeq double %2, %3 58 %5 = zext i1 %4 to i32 59 ret i32 %5 60; CHECK-LABEL: @test5( 61; CHECK-NEXT: %rintf = call float @rintf(float %x) 62; CHECK-NEXT: fcmp oeq float %rintf, %y 63} 64 65define i32 @test6(float %x, float %y) nounwind uwtable { 66 %1 = fpext float %x to double 67 %2 = call double @round(double %1) nounwind readnone 68 %3 = fpext float %y to double 69 %4 = fcmp oeq double %2, %3 70 %5 = zext i1 %4 to i32 71 ret i32 %5 72; CHECK-LABEL: @test6( 73; CHECK-NEXT: %roundf = call float @roundf(float %x) 74; CHECK-NEXT: fcmp oeq float %roundf, %y 75} 76 77define i32 @test7(float %x, float %y) nounwind uwtable { 78 %1 = fpext float %x to double 79 %2 = call double @trunc(double %1) nounwind 80 %3 = fpext float %y to double 81 %4 = fcmp oeq double %2, %3 82 %5 = zext i1 %4 to i32 83 ret i32 %5 84; CHECK-LABEL: @test7( 85; CHECK-NEXT: %truncf = call float @truncf(float %x) 86; CHECK-NEXT: fcmp oeq float %truncf, %y 87} 88 89define i32 @test8(float %x, float %y) nounwind uwtable { 90 %1 = fpext float %y to double 91 %2 = fpext float %x to double 92 %3 = call double @ceil(double %2) nounwind readnone 93 %4 = fcmp oeq double %1, %3 94 %5 = zext i1 %4 to i32 95 ret i32 %5 96; CHECK-LABEL: @test8( 97; CHECK-NEXT: %ceilf = call float @ceilf(float %x) 98; CHECK-NEXT: fcmp oeq float %ceilf, %y 99} 100 101define i32 @test9(float %x, float %y) nounwind uwtable { 102 %1 = fpext float %y to double 103 %2 = fpext float %x to double 104 %3 = call double @fabs(double %2) nounwind readnone 105 %4 = fcmp oeq double %1, %3 106 %5 = zext i1 %4 to i32 107 ret i32 %5 108; CHECK-LABEL: @test9( 109; CHECK-NEXT: %fabsf = call float @fabsf(float %x) 110; CHECK-NEXT: fcmp oeq float %fabsf, %y 111} 112 113define i32 @test10(float %x, float %y) nounwind uwtable { 114 %1 = fpext float %y to double 115 %2 = fpext float %x to double 116 %3 = call double @floor(double %2) nounwind readnone 117 %4 = fcmp oeq double %1, %3 118 %5 = zext i1 %4 to i32 119 ret i32 %5 120; CHECK-LABEL: @test10( 121; CHECK-NEXT: %floorf = call float @floorf(float %x) 122; CHECK-NEXT: fcmp oeq float %floorf, %y 123} 124 125define i32 @test11(float %x, float %y) nounwind uwtable { 126 %1 = fpext float %y to double 127 %2 = fpext float %x to double 128 %3 = call double @nearbyint(double %2) nounwind 129 %4 = fcmp oeq double %1, %3 130 %5 = zext i1 %4 to i32 131 ret i32 %5 132; CHECK-LABEL: @test11( 133; CHECK-NEXT: %nearbyintf = call float @nearbyintf(float %x) 134; CHECK-NEXT: fcmp oeq float %nearbyintf, %y 135} 136 137define i32 @test12(float %x, float %y) nounwind uwtable { 138 %1 = fpext float %y to double 139 %2 = fpext float %x to double 140 %3 = call double @rint(double %2) nounwind 141 %4 = fcmp oeq double %1, %3 142 %5 = zext i1 %4 to i32 143 ret i32 %5 144; CHECK-LABEL: @test12( 145; CHECK-NEXT: %rintf = call float @rintf(float %x) 146; CHECK-NEXT: fcmp oeq float %rintf, %y 147} 148 149define i32 @test13(float %x, float %y) nounwind uwtable { 150 %1 = fpext float %y to double 151 %2 = fpext float %x to double 152 %3 = call double @round(double %2) nounwind readnone 153 %4 = fcmp oeq double %1, %3 154 %5 = zext i1 %4 to i32 155 ret i32 %5 156; CHECK-LABEL: @test13( 157; CHECK-NEXT: %roundf = call float @roundf(float %x) 158; CHECK-NEXT: fcmp oeq float %roundf, %y 159} 160 161define i32 @test14(float %x, float %y) nounwind uwtable { 162 %1 = fpext float %y to double 163 %2 = fpext float %x to double 164 %3 = call double @trunc(double %2) nounwind 165 %4 = fcmp oeq double %1, %3 166 %5 = zext i1 %4 to i32 167 ret i32 %5 168; CHECK-LABEL: @test14( 169; CHECK-NEXT: %truncf = call float @truncf(float %x) 170; CHECK-NEXT: fcmp oeq float %truncf, %y 171} 172 173define i32 @test15(float %x, float %y, float %z) nounwind uwtable { 174 %1 = fpext float %x to double 175 %2 = fpext float %y to double 176 %3 = call double @fmin(double %1, double %2) nounwind 177 %4 = fpext float %z to double 178 %5 = fcmp oeq double %3, %4 179 %6 = zext i1 %5 to i32 180 ret i32 %6 181; CHECK-LABEL: @test15( 182; CHECK-NEXT: %fminf = call float @fminf(float %x, float %y) 183; CHECK-NEXT: fcmp oeq float %fminf, %z 184} 185 186define i32 @test16(float %x, float %y, float %z) nounwind uwtable { 187 %1 = fpext float %z to double 188 %2 = fpext float %x to double 189 %3 = fpext float %y to double 190 %4 = call double @fmin(double %2, double %3) nounwind 191 %5 = fcmp oeq double %1, %4 192 %6 = zext i1 %5 to i32 193 ret i32 %6 194; CHECK-LABEL: @test16( 195; CHECK-NEXT: %fminf = call float @fminf(float %x, float %y) 196; CHECK-NEXT: fcmp oeq float %fminf, %z 197} 198 199define i32 @test17(float %x, float %y, float %z) nounwind uwtable { 200 %1 = fpext float %x to double 201 %2 = fpext float %y to double 202 %3 = call double @fmax(double %1, double %2) nounwind 203 %4 = fpext float %z to double 204 %5 = fcmp oeq double %3, %4 205 %6 = zext i1 %5 to i32 206 ret i32 %6 207; CHECK-LABEL: @test17( 208; CHECK-NEXT: %fmaxf = call float @fmaxf(float %x, float %y) 209; CHECK-NEXT: fcmp oeq float %fmaxf, %z 210} 211 212define i32 @test18(float %x, float %y, float %z) nounwind uwtable { 213 %1 = fpext float %z to double 214 %2 = fpext float %x to double 215 %3 = fpext float %y to double 216 %4 = call double @fmax(double %2, double %3) nounwind 217 %5 = fcmp oeq double %1, %4 218 %6 = zext i1 %5 to i32 219 ret i32 %6 220; CHECK-LABEL: @test18( 221; CHECK-NEXT: %fmaxf = call float @fmaxf(float %x, float %y) 222; CHECK-NEXT: fcmp oeq float %fmaxf, %z 223} 224 225define i32 @test19(float %x, float %y, float %z) nounwind uwtable { 226 %1 = fpext float %x to double 227 %2 = fpext float %y to double 228 %3 = call double @copysign(double %1, double %2) nounwind 229 %4 = fpext float %z to double 230 %5 = fcmp oeq double %3, %4 231 %6 = zext i1 %5 to i32 232 ret i32 %6 233; CHECK-LABEL: @test19( 234; CHECK-NEXT: %copysignf = call float @copysignf(float %x, float %y) 235; CHECK-NEXT: fcmp oeq float %copysignf, %z 236} 237 238define i32 @test20(float %x, float %y) nounwind uwtable { 239 %1 = fpext float %y to double 240 %2 = fpext float %x to double 241 %3 = call double @fmin(double 1.000000e+00, double %2) nounwind 242 %4 = fcmp oeq double %1, %3 243 %5 = zext i1 %4 to i32 244 ret i32 %5 245; CHECK-LABEL: @test20( 246; CHECK-NEXT: %fminf = call float @fminf(float 1.000000e+00, float %x) 247; CHECK-NEXT: fcmp oeq float %fminf, %y 248} 249 250define i32 @test21(float %x, float %y) nounwind uwtable { 251 %1 = fpext float %y to double 252 %2 = fpext float %x to double 253 %3 = call double @fmin(double 1.300000e+00, double %2) nounwind 254 %4 = fcmp oeq double %1, %3 255 %5 = zext i1 %4 to i32 256 ret i32 %5 257; should not be changed to fminf as the constant would loose precision 258; CHECK-LABEL: @test21( 259; CHECK: %3 = call double @fmin(double 1.300000e+00, double %2) 260} 261 262declare double @fabs(double) nounwind readnone 263declare double @ceil(double) nounwind readnone 264declare double @copysign(double, double) nounwind readnone 265declare double @floor(double) nounwind readnone 266declare double @nearbyint(double) nounwind readnone 267declare double @rint(double) nounwind readnone 268declare double @round(double) nounwind readnone 269declare double @trunc(double) nounwind readnone 270declare double @fmin(double, double) nounwind readnone 271declare double @fmax(double, double) nounwind readnone 272