calls.ll 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ; RUN: opt < %s -constprop -S | FileCheck %s
  2. ; RUN: opt < %s -constprop -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
  3. declare double @cos(double)
  4. declare double @sin(double)
  5. declare double @tan(double)
  6. declare double @sqrt(double)
  7. declare double @exp2(double)
  8. define double @T() {
  9. ; CHECK-LABEL: @T(
  10. ; CHECK-NOT: call
  11. ; CHECK: ret
  12. %A = call double @cos(double 0.000000e+00)
  13. %B = call double @sin(double 0.000000e+00)
  14. %a = fadd double %A, %B
  15. %C = call double @tan(double 0.000000e+00)
  16. %b = fadd double %a, %C
  17. %D = call double @sqrt(double 4.000000e+00)
  18. %c = fadd double %b, %D
  19. ; PR9315
  20. %E = call double @exp2(double 4.0)
  21. %d = fadd double %c, %E
  22. ret double %d
  23. }
  24. define i1 @test_sse_cvt() nounwind readnone {
  25. ; CHECK-LABEL: @test_sse_cvt(
  26. ; CHECK-NOT: call
  27. ; CHECK: ret i1 true
  28. entry:
  29. %i0 = tail call i32 @llvm.x86.sse.cvtss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
  30. %i1 = tail call i32 @llvm.x86.sse.cvttss2si(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
  31. %i2 = tail call i64 @llvm.x86.sse.cvtss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
  32. %i3 = tail call i64 @llvm.x86.sse.cvttss2si64(<4 x float> <float 1.75, float undef, float undef, float undef>) nounwind
  33. %i4 = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> <double 1.75, double undef>) nounwind
  34. %i5 = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> <double 1.75, double undef>) nounwind
  35. %i6 = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> <double 1.75, double undef>) nounwind
  36. %i7 = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> <double 1.75, double undef>) nounwind
  37. %sum11 = add i32 %i0, %i1
  38. %sum12 = add i32 %i4, %i5
  39. %sum1 = add i32 %sum11, %sum12
  40. %sum21 = add i64 %i2, %i3
  41. %sum22 = add i64 %i6, %i7
  42. %sum2 = add i64 %sum21, %sum22
  43. %sum1.sext = sext i32 %sum1 to i64
  44. %b = icmp eq i64 %sum1.sext, %sum2
  45. ret i1 %b
  46. }
  47. declare i32 @llvm.x86.sse.cvtss2si(<4 x float>) nounwind readnone
  48. declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) nounwind readnone
  49. declare i64 @llvm.x86.sse.cvtss2si64(<4 x float>) nounwind readnone
  50. declare i64 @llvm.x86.sse.cvttss2si64(<4 x float>) nounwind readnone
  51. declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone
  52. declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone
  53. declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone
  54. declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone
  55. define double @test_intrinsic_pow() nounwind uwtable ssp {
  56. entry:
  57. ; CHECK-LABEL: @test_intrinsic_pow(
  58. ; CHECK-NOT: call
  59. %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00)
  60. ret double %0
  61. }
  62. declare double @llvm.pow.f64(double, double) nounwind readonly
  63. ; Shouldn't fold because of -fno-builtin
  64. define double @sin_() nounwind uwtable ssp {
  65. ; FNOBUILTIN-LABEL: @sin_(
  66. ; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00)
  67. %1 = call double @sin(double 3.000000e+00)
  68. ret double %1
  69. }
  70. ; Shouldn't fold because of -fno-builtin
  71. define double @sqrt_() nounwind uwtable ssp {
  72. ; FNOBUILTIN-LABEL: @sqrt_(
  73. ; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00)
  74. %1 = call double @sqrt(double 3.000000e+00)
  75. ret double %1
  76. }
  77. ; Shouldn't fold because of -fno-builtin
  78. define float @sqrtf_() nounwind uwtable ssp {
  79. ; FNOBUILTIN-LABEL: @sqrtf_(
  80. ; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00)
  81. %1 = call float @sqrtf(float 3.000000e+00)
  82. ret float %1
  83. }
  84. declare float @sqrtf(float)
  85. ; Shouldn't fold because of -fno-builtin
  86. define float @sinf_() nounwind uwtable ssp {
  87. ; FNOBUILTIN-LABEL: @sinf_(
  88. ; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00)
  89. %1 = call float @sinf(float 3.000000e+00)
  90. ret float %1
  91. }
  92. declare float @sinf(float)
  93. ; Shouldn't fold because of -fno-builtin
  94. define double @tan_() nounwind uwtable ssp {
  95. ; FNOBUILTIN-LABEL: @tan_(
  96. ; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00)
  97. %1 = call double @tan(double 3.000000e+00)
  98. ret double %1
  99. }
  100. ; Shouldn't fold because of -fno-builtin
  101. define double @tanh_() nounwind uwtable ssp {
  102. ; FNOBUILTIN-LABEL: @tanh_(
  103. ; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00)
  104. %1 = call double @tanh(double 3.000000e+00)
  105. ret double %1
  106. }
  107. declare double @tanh(double)
  108. ; Shouldn't fold because of -fno-builtin
  109. define double @pow_() nounwind uwtable ssp {
  110. ; FNOBUILTIN-LABEL: @pow_(
  111. ; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
  112. %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
  113. ret double %1
  114. }
  115. declare double @pow(double, double)
  116. ; Shouldn't fold because of -fno-builtin
  117. define double @fmod_() nounwind uwtable ssp {
  118. ; FNOBUILTIN-LABEL: @fmod_(
  119. ; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
  120. %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
  121. ret double %1
  122. }
  123. declare double @fmod(double, double)
  124. ; Shouldn't fold because of -fno-builtin
  125. define double @atan2_() nounwind uwtable ssp {
  126. ; FNOBUILTIN-LABEL: @atan2_(
  127. ; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
  128. %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
  129. ret double %1
  130. }
  131. declare double @atan2(double, double)