inline-fp.ll 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ; RUN: opt -S -inline < %s | FileCheck %s
  2. ; Make sure that soft float implementations are calculated as being more expensive
  3. ; to the inliner.
  4. define i32 @test_nofp() #0 {
  5. ; f_nofp() has the "use-soft-float" attribute, so it should never get inlined.
  6. ; CHECK-LABEL: test_nofp
  7. ; CHECK: call float @f_nofp
  8. entry:
  9. %responseX = alloca i32, align 4
  10. %responseY = alloca i32, align 4
  11. %responseZ = alloca i32, align 4
  12. %valueX = alloca i8, align 1
  13. %valueY = alloca i8, align 1
  14. %valueZ = alloca i8, align 1
  15. call void @getX(i32* %responseX, i8* %valueX)
  16. call void @getY(i32* %responseY, i8* %valueY)
  17. call void @getZ(i32* %responseZ, i8* %valueZ)
  18. %0 = load i32, i32* %responseX
  19. %1 = load i8, i8* %valueX
  20. %call = call float @f_nofp(i32 %0, i8 zeroext %1)
  21. %2 = load i32, i32* %responseZ
  22. %3 = load i8, i8* %valueZ
  23. %call2 = call float @f_nofp(i32 %2, i8 zeroext %3)
  24. %call3 = call float @fabsf(float %call)
  25. %cmp = fcmp ogt float %call3, 0x3FC1EB8520000000
  26. br i1 %cmp, label %if.end12, label %if.else
  27. if.else: ; preds = %entry
  28. %4 = load i32, i32* %responseY
  29. %5 = load i8, i8* %valueY
  30. %call1 = call float @f_nofp(i32 %4, i8 zeroext %5)
  31. %call4 = call float @fabsf(float %call1)
  32. %cmp5 = fcmp ogt float %call4, 0x3FC1EB8520000000
  33. br i1 %cmp5, label %if.end12, label %if.else7
  34. if.else7: ; preds = %if.else
  35. %call8 = call float @fabsf(float %call2)
  36. %cmp9 = fcmp ogt float %call8, 0x3FC1EB8520000000
  37. br i1 %cmp9, label %if.then10, label %if.end12
  38. if.then10: ; preds = %if.else7
  39. br label %if.end12
  40. if.end12: ; preds = %if.else, %entry, %if.then10, %if.else7
  41. %success.0 = phi i32 [ 0, %if.then10 ], [ 1, %if.else7 ], [ 0, %entry ], [ 0, %if.else ]
  42. ret i32 %success.0
  43. }
  44. define i32 @test_hasfp() #0 {
  45. ; f_hasfp() does not have the "use-soft-float" attribute, so it should get inlined.
  46. ; CHECK-LABEL: test_hasfp
  47. ; CHECK-NOT: call float @f_hasfp
  48. entry:
  49. %responseX = alloca i32, align 4
  50. %responseY = alloca i32, align 4
  51. %responseZ = alloca i32, align 4
  52. %valueX = alloca i8, align 1
  53. %valueY = alloca i8, align 1
  54. %valueZ = alloca i8, align 1
  55. call void @getX(i32* %responseX, i8* %valueX)
  56. call void @getY(i32* %responseY, i8* %valueY)
  57. call void @getZ(i32* %responseZ, i8* %valueZ)
  58. %0 = load i32, i32* %responseX
  59. %1 = load i8, i8* %valueX
  60. %call = call float @f_hasfp(i32 %0, i8 zeroext %1)
  61. %2 = load i32, i32* %responseZ
  62. %3 = load i8, i8* %valueZ
  63. %call2 = call float @f_hasfp(i32 %2, i8 zeroext %3)
  64. %call3 = call float @fabsf(float %call)
  65. %cmp = fcmp ogt float %call3, 0x3FC1EB8520000000
  66. br i1 %cmp, label %if.end12, label %if.else
  67. if.else: ; preds = %entry
  68. %4 = load i32, i32* %responseY
  69. %5 = load i8, i8* %valueY
  70. %call1 = call float @f_hasfp(i32 %4, i8 zeroext %5)
  71. %call4 = call float @fabsf(float %call1)
  72. %cmp5 = fcmp ogt float %call4, 0x3FC1EB8520000000
  73. br i1 %cmp5, label %if.end12, label %if.else7
  74. if.else7: ; preds = %if.else
  75. %call8 = call float @fabsf(float %call2)
  76. %cmp9 = fcmp ogt float %call8, 0x3FC1EB8520000000
  77. br i1 %cmp9, label %if.then10, label %if.end12
  78. if.then10: ; preds = %if.else7
  79. br label %if.end12
  80. if.end12: ; preds = %if.else, %entry, %if.then10, %if.else7
  81. %success.0 = phi i32 [ 0, %if.then10 ], [ 1, %if.else7 ], [ 0, %entry ], [ 0, %if.else ]
  82. ret i32 %success.0
  83. }
  84. declare void @getX(i32*, i8*) #0
  85. declare void @getY(i32*, i8*) #0
  86. declare void @getZ(i32*, i8*) #0
  87. define internal float @f_hasfp(i32 %response, i8 zeroext %value1) #0 {
  88. entry:
  89. %conv = zext i8 %value1 to i32
  90. %sub = add nsw i32 %conv, -1
  91. %conv1 = sitofp i32 %sub to float
  92. %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
  93. %mul = fmul float %0, 2.620000e+03
  94. %conv2 = sitofp i32 %response to float
  95. %sub3 = fsub float %conv2, %mul
  96. %div = fdiv float %sub3, %mul
  97. ret float %div
  98. }
  99. define internal float @f_nofp(i32 %response, i8 zeroext %value1) #1 {
  100. entry:
  101. %conv = zext i8 %value1 to i32
  102. %sub = add nsw i32 %conv, -1
  103. %conv1 = sitofp i32 %sub to float
  104. %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1)
  105. %mul = fmul float %0, 2.620000e+03
  106. %conv2 = sitofp i32 %response to float
  107. %sub3 = fsub float %conv2, %mul
  108. %div = fdiv float %sub3, %mul
  109. ret float %div
  110. }
  111. declare float @fabsf(float) optsize minsize
  112. declare float @llvm.pow.f32(float, float) optsize minsize
  113. attributes #0 = { minsize optsize }
  114. attributes #1 = { minsize optsize "use-soft-float"="true" }