1; RUN: opt < %s -simplifycfg -instcombine -S | grep 0x3FB99999A0000000 | count 2 2; RUN: opt < %s -simplifycfg -instcombine -S | grep 0xBFB99999A0000000 | count 2 3; check constant folding for 'frem'. PR 3316. 4 5; ModuleID = 'tt.c' 6target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" 7target triple = "i386-apple-darwin9.6" 8 9define float @test1() nounwind { 10entry: 11 %retval = alloca float ; <float*> [#uses=2] 12 %0 = alloca float ; <float*> [#uses=2] 13 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 14 %1 = frem double 1.000000e-01, 1.000000e+00 ; <double> [#uses=1] 15 %2 = fptrunc double %1 to float ; <float> [#uses=1] 16 store float %2, float* %0, align 4 17 %3 = load float, float* %0, align 4 ; <float> [#uses=1] 18 store float %3, float* %retval, align 4 19 br label %return 20 21return: ; preds = %entry 22 %retval1 = load float, float* %retval ; <float> [#uses=1] 23 ret float %retval1 24} 25 26define float @test2() nounwind { 27entry: 28 %retval = alloca float ; <float*> [#uses=2] 29 %0 = alloca float ; <float*> [#uses=2] 30 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 31 %1 = frem double -1.000000e-01, 1.000000e+00 ; <double> [#uses=1] 32 %2 = fptrunc double %1 to float ; <float> [#uses=1] 33 store float %2, float* %0, align 4 34 %3 = load float, float* %0, align 4 ; <float> [#uses=1] 35 store float %3, float* %retval, align 4 36 br label %return 37 38return: ; preds = %entry 39 %retval1 = load float, float* %retval ; <float> [#uses=1] 40 ret float %retval1 41} 42 43define float @test3() nounwind { 44entry: 45 %retval = alloca float ; <float*> [#uses=2] 46 %0 = alloca float ; <float*> [#uses=2] 47 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 48 %1 = frem double 1.000000e-01, -1.000000e+00 ; <double> [#uses=1] 49 %2 = fptrunc double %1 to float ; <float> [#uses=1] 50 store float %2, float* %0, align 4 51 %3 = load float, float* %0, align 4 ; <float> [#uses=1] 52 store float %3, float* %retval, align 4 53 br label %return 54 55return: ; preds = %entry 56 %retval1 = load float, float* %retval ; <float> [#uses=1] 57 ret float %retval1 58} 59 60define float @test4() nounwind { 61entry: 62 %retval = alloca float ; <float*> [#uses=2] 63 %0 = alloca float ; <float*> [#uses=2] 64 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 65 %1 = frem double -1.000000e-01, -1.000000e+00 ; <double> [#uses=1] 66 %2 = fptrunc double %1 to float ; <float> [#uses=1] 67 store float %2, float* %0, align 4 68 %3 = load float, float* %0, align 4 ; <float> [#uses=1] 69 store float %3, float* %retval, align 4 70 br label %return 71 72return: ; preds = %entry 73 %retval1 = load float, float* %retval ; <float> [#uses=1] 74 ret float %retval1 75} 76