round.ll 2.5 KB

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