Karthik Bhat | b67688a | 2014-03-07 04:36:21 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -instcombine < %s | FileCheck %s |
| 2 | |
| 3 | declare float @llvm.round.f32(float) #0 |
| 4 | declare double @llvm.round.f64(double) #0 |
| 5 | |
| 6 | ; CHECK-LABEL: @constant_fold_round_f32_01 |
| 7 | ; CHECK-NEXT: ret float 1.000000e+00 |
| 8 | define float @constant_fold_round_f32_01() #0 { |
| 9 | %x = call float @llvm.round.f32(float 1.25) #0 |
| 10 | ret float %x |
| 11 | } |
| 12 | |
| 13 | ; CHECK-LABEL: @constant_fold_round_f32_02 |
| 14 | ; CHECK-NEXT: ret float -1.000000e+00 |
| 15 | define float @constant_fold_round_f32_02() #0 { |
| 16 | %x = call float @llvm.round.f32(float -1.25) #0 |
| 17 | ret float %x |
| 18 | } |
| 19 | |
| 20 | ; CHECK-LABEL: @constant_fold_round_f32_03 |
| 21 | ; CHECK-NEXT: ret float 2.000000e+00 |
| 22 | define float @constant_fold_round_f32_03() #0 { |
| 23 | %x = call float @llvm.round.f32(float 1.5) #0 |
| 24 | ret float %x |
| 25 | } |
| 26 | |
| 27 | ; CHECK-LABEL: @constant_fold_round_f32_04 |
| 28 | ; CHECK-NEXT: ret float -2.000000e+00 |
| 29 | define float @constant_fold_round_f32_04() #0 { |
| 30 | %x = call float @llvm.round.f32(float -1.5) #0 |
| 31 | ret float %x |
| 32 | } |
| 33 | |
| 34 | ; CHECK-LABEL: @constant_fold_round_f32_05 |
| 35 | ; CHECK-NEXT: ret float 3.000000e+00 |
| 36 | define float @constant_fold_round_f32_05() #0 { |
| 37 | %x = call float @llvm.round.f32(float 2.75) #0 |
| 38 | ret float %x |
| 39 | } |
| 40 | |
| 41 | ; CHECK-LABEL: @constant_fold_round_f32_06 |
| 42 | ; CHECK-NEXT: ret float -3.000000e+00 |
| 43 | define float @constant_fold_round_f32_06() #0 { |
| 44 | %x = call float @llvm.round.f32(float -2.75) #0 |
| 45 | ret float %x |
| 46 | } |
| 47 | |
| 48 | ; CHECK-LABEL: @constant_fold_round_f64_01 |
| 49 | ; CHECK-NEXT: ret double 1.000000e+00 |
| 50 | define double @constant_fold_round_f64_01() #0 { |
| 51 | %x = call double @llvm.round.f64(double 1.3) #0 |
| 52 | ret double %x |
| 53 | } |
| 54 | |
| 55 | ; CHECK-LABEL: @constant_fold_round_f64_02 |
| 56 | ; CHECK-NEXT: ret double -1.000000e+00 |
| 57 | define double @constant_fold_round_f64_02() #0 { |
| 58 | %x = call double @llvm.round.f64(double -1.3) #0 |
| 59 | ret double %x |
| 60 | } |
| 61 | |
| 62 | ; CHECK-LABEL: @constant_fold_round_f64_03 |
| 63 | ; CHECK-NEXT: ret double 2.000000e+00 |
| 64 | define double @constant_fold_round_f64_03() #0 { |
| 65 | %x = call double @llvm.round.f64(double 1.5) #0 |
| 66 | ret double %x |
| 67 | } |
| 68 | |
| 69 | ; CHECK-LABEL: @constant_fold_round_f64_04 |
| 70 | ; CHECK-NEXT: ret double -2.000000e+00 |
| 71 | define double @constant_fold_round_f64_04() #0 { |
| 72 | %x = call double @llvm.round.f64(double -1.5) #0 |
| 73 | ret double %x |
| 74 | } |
| 75 | |
| 76 | ; CHECK-LABEL: @constant_fold_round_f64_05 |
| 77 | ; CHECK-NEXT: ret double 3.000000e+00 |
| 78 | define double @constant_fold_round_f64_05() #0 { |
| 79 | %x = call double @llvm.round.f64(double 2.7) #0 |
| 80 | ret double %x |
| 81 | } |
| 82 | |
| 83 | ; CHECK-LABEL: @constant_fold_round_f64_06 |
| 84 | ; CHECK-NEXT: ret double -3.000000e+00 |
| 85 | define double @constant_fold_round_f64_06() #0 { |
| 86 | %x = call double @llvm.round.f64(double -2.7) #0 |
| 87 | ret double %x |
| 88 | } |
| 89 | |
| 90 | attributes #0 = { nounwind readnone } |