speculate-math.ll 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ; RUN: opt -S -simplifycfg -phi-node-folding-threshold=2 < %s | FileCheck %s
  2. declare float @llvm.sqrt.f32(float) nounwind readonly
  3. declare float @llvm.fma.f32(float, float, float) nounwind readonly
  4. declare float @llvm.fmuladd.f32(float, float, float) nounwind readonly
  5. declare float @llvm.fabs.f32(float) nounwind readonly
  6. declare float @llvm.minnum.f32(float, float) nounwind readonly
  7. declare float @llvm.maxnum.f32(float, float) nounwind readonly
  8. ; CHECK-LABEL: @sqrt_test(
  9. ; CHECK: select
  10. define void @sqrt_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
  11. entry:
  12. %cmp.i = fcmp olt float %a, 0.000000e+00
  13. br i1 %cmp.i, label %test_sqrt.exit, label %cond.else.i
  14. cond.else.i: ; preds = %entry
  15. %0 = tail call float @llvm.sqrt.f32(float %a) nounwind readnone
  16. br label %test_sqrt.exit
  17. test_sqrt.exit: ; preds = %cond.else.i, %entry
  18. %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
  19. store float %cond.i, float addrspace(1)* %out, align 4
  20. ret void
  21. }
  22. ; CHECK-LABEL: @fabs_test(
  23. ; CHECK: select
  24. define void @fabs_test(float addrspace(1)* noalias nocapture %out, float %a) nounwind {
  25. entry:
  26. %cmp.i = fcmp olt float %a, 0.000000e+00
  27. br i1 %cmp.i, label %test_fabs.exit, label %cond.else.i
  28. cond.else.i: ; preds = %entry
  29. %0 = tail call float @llvm.fabs.f32(float %a) nounwind readnone
  30. br label %test_fabs.exit
  31. test_fabs.exit: ; preds = %cond.else.i, %entry
  32. %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
  33. store float %cond.i, float addrspace(1)* %out, align 4
  34. ret void
  35. }
  36. ; CHECK-LABEL: @fma_test(
  37. ; CHECK: select
  38. define void @fma_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
  39. entry:
  40. %cmp.i = fcmp olt float %a, 0.000000e+00
  41. br i1 %cmp.i, label %test_fma.exit, label %cond.else.i
  42. cond.else.i: ; preds = %entry
  43. %0 = tail call float @llvm.fma.f32(float %a, float %b, float %c) nounwind readnone
  44. br label %test_fma.exit
  45. test_fma.exit: ; preds = %cond.else.i, %entry
  46. %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
  47. store float %cond.i, float addrspace(1)* %out, align 4
  48. ret void
  49. }
  50. ; CHECK-LABEL: @fmuladd_test(
  51. ; CHECK: select
  52. define void @fmuladd_test(float addrspace(1)* noalias nocapture %out, float %a, float %b, float %c) nounwind {
  53. entry:
  54. %cmp.i = fcmp olt float %a, 0.000000e+00
  55. br i1 %cmp.i, label %test_fmuladd.exit, label %cond.else.i
  56. cond.else.i: ; preds = %entry
  57. %0 = tail call float @llvm.fmuladd.f32(float %a, float %b, float %c) nounwind readnone
  58. br label %test_fmuladd.exit
  59. test_fmuladd.exit: ; preds = %cond.else.i, %entry
  60. %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
  61. store float %cond.i, float addrspace(1)* %out, align 4
  62. ret void
  63. }
  64. ; CHECK-LABEL: @minnum_test(
  65. ; CHECK: select
  66. define void @minnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
  67. entry:
  68. %cmp.i = fcmp olt float %a, 0.000000e+00
  69. br i1 %cmp.i, label %test_minnum.exit, label %cond.else.i
  70. cond.else.i: ; preds = %entry
  71. %0 = tail call float @llvm.minnum.f32(float %a, float %b) nounwind readnone
  72. br label %test_minnum.exit
  73. test_minnum.exit: ; preds = %cond.else.i, %entry
  74. %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
  75. store float %cond.i, float addrspace(1)* %out, align 4
  76. ret void
  77. }
  78. ; CHECK-LABEL: @maxnum_test(
  79. ; CHECK: select
  80. define void @maxnum_test(float addrspace(1)* noalias nocapture %out, float %a, float %b) nounwind {
  81. entry:
  82. %cmp.i = fcmp olt float %a, 0.000000e+00
  83. br i1 %cmp.i, label %test_maxnum.exit, label %cond.else.i
  84. cond.else.i: ; preds = %entry
  85. %0 = tail call float @llvm.maxnum.f32(float %a, float %b) nounwind readnone
  86. br label %test_maxnum.exit
  87. test_maxnum.exit: ; preds = %cond.else.i, %entry
  88. %cond.i = phi float [ %0, %cond.else.i ], [ 0x7FF8000000000000, %entry ]
  89. store float %cond.i, float addrspace(1)* %out, align 4
  90. ret void
  91. }