convert-from-fp16.ll 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ; RUN: opt -constprop -S < %s | FileCheck %s
  2. ; Verify that we don't crash with an assertion failure when constant folding
  3. ; a call to intrinsic 'convert.from.fp16' if the return type is not 'float'.
  4. define float @fold_from_fp16_to_fp32() {
  5. ; CHECK-LABEL: @fold_from_fp16_to_fp32
  6. ; CHECK: ret float 0.000000e+00
  7. entry:
  8. %0 = call float @llvm.convert.from.fp16.f32(i16 0)
  9. ret float %0
  10. }
  11. define double @fold_from_fp16_to_fp64() {
  12. ; CHECK-LABEL: @fold_from_fp16_to_fp64
  13. ; CHECK: ret double 0.000000e+00
  14. entry:
  15. %0 = call double @llvm.convert.from.fp16.f64(i16 0)
  16. ret double %0
  17. }
  18. define x86_fp80 @fold_from_fp16_to_fp80() {
  19. ; CHECK-LABEL: @fold_from_fp16_to_fp80
  20. ; CHECK: ret x86_fp80 0xK00000000000000000000
  21. entry:
  22. %0 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 0)
  23. ret x86_fp80 %0
  24. }
  25. define fp128 @fold_from_fp16_to_fp128() {
  26. ; CHECK-LABEL: @fold_from_fp16_to_fp128
  27. ; CHECK: ret fp128 0xL00000000000000000000000000000000
  28. entry:
  29. %0 = call fp128 @llvm.convert.from.fp16.f128(i16 0)
  30. ret fp128 %0
  31. }
  32. define ppc_fp128 @fold_from_fp16_to_ppcfp128() {
  33. ; CHECK-LABEL: @fold_from_fp16_to_ppcfp128
  34. ; CHECK: ret ppc_fp128 0xM00000000000000000000000000000000
  35. entry:
  36. %0 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 0)
  37. ret ppc_fp128 %0
  38. }
  39. define float @fold_from_fp16_to_fp32_b() {
  40. ; CHECK-LABEL: @fold_from_fp16_to_fp32_b
  41. ; CHECK: ret float 4.000000e+00
  42. entry:
  43. %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  44. %1 = call float @llvm.convert.from.fp16.f32(i16 %0)
  45. ret float %1
  46. }
  47. define double @fold_from_fp16_to_fp64_b() {
  48. ; CHECK-LABEL: @fold_from_fp16_to_fp64_b
  49. ; CHECK: ret double 4.000000e+00
  50. entry:
  51. %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  52. %1 = call double @llvm.convert.from.fp16.f64(i16 %0)
  53. ret double %1
  54. }
  55. define x86_fp80 @fold_from_fp16_to_fp80_b() {
  56. ; CHECK-LABEL: @fold_from_fp16_to_fp80_b
  57. ; CHECK: ret x86_fp80 0xK40018000000000000000
  58. entry:
  59. %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  60. %1 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 %0)
  61. ret x86_fp80 %1
  62. }
  63. define fp128 @fold_from_fp16_to_fp128_b() {
  64. ; CHECK-LABEL: @fold_from_fp16_to_fp128_b
  65. ; CHECK: ret fp128 0xL00000000000000004001000000000000
  66. entry:
  67. %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  68. %1 = call fp128 @llvm.convert.from.fp16.f128(i16 %0)
  69. ret fp128 %1
  70. }
  71. define ppc_fp128 @fold_from_fp16_to_ppcfp128_b() {
  72. ; CHECK-LABEL: @fold_from_fp16_to_ppcfp128_b
  73. ; CHECK: ret ppc_fp128 0xM40100000000000000000000000000000
  74. entry:
  75. %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  76. %1 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 %0)
  77. ret ppc_fp128 %1
  78. }
  79. declare i16 @llvm.convert.to.fp16.f64(double)
  80. declare float @llvm.convert.from.fp16.f32(i16)
  81. declare double @llvm.convert.from.fp16.f64(i16)
  82. declare x86_fp80 @llvm.convert.from.fp16.f80(i16)
  83. declare fp128 @llvm.convert.from.fp16.f128(i16)
  84. declare ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16)