[flang-commits] [flang] 418d233 - [flang] Remove fp128 support for llvm.round and llvm.trunc

Peixin Qiao via flang-commits flang-commits at lists.llvm.org
Tue Jul 26 05:23:28 PDT 2022


Author: Peixin Qiao
Date: 2022-07-26T20:21:51+08:00
New Revision: 418d2338f9bad03e002ca1a301ce537102a2f142

URL: https://github.com/llvm/llvm-project/commit/418d2338f9bad03e002ca1a301ce537102a2f142
DIFF: https://github.com/llvm/llvm-project/commit/418d2338f9bad03e002ca1a301ce537102a2f142.diff

LOG: [flang] Remove fp128 support for llvm.round and llvm.trunc

The fp128 in llvm.round and llvm.trunc is not supported in X86_64 for
now. Revert the support. To support quad precision for llvm.round and
llvm.trunc, it may should be supported using runtime.

Reviewed By: Jean Perier

Differential Revision: https://reviews.llvm.org/D130556

Added: 
    

Modified: 
    flang/lib/Lower/IntrinsicCall.cpp
    flang/test/Lower/Intrinsics/aint.f90
    flang/test/Lower/Intrinsics/anint.f90
    flang/test/Lower/math-lowering.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 4f5c8b2c5b109..826404e80c536 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -1208,7 +1208,6 @@ static constexpr MathOperation mathOperations[] = {
     {"aint", "llvm.trunc.f32", genF32F32FuncType, genLibCall},
     {"aint", "llvm.trunc.f64", genF64F64FuncType, genLibCall},
     {"aint", "llvm.trunc.f80", genF80F80FuncType, genLibCall},
-    {"aint", "llvm.trunc.f128", genF128F128FuncType, genLibCall},
     // llvm.round behaves the same way as libm's round.
     {"anint", "llvm.round.f32", genF32F32FuncType,
      genMathOp<mlir::LLVM::RoundOp>},
@@ -1216,8 +1215,6 @@ static constexpr MathOperation mathOperations[] = {
      genMathOp<mlir::LLVM::RoundOp>},
     {"anint", "llvm.round.f80", genF80F80FuncType,
      genMathOp<mlir::LLVM::RoundOp>},
-    {"anint", "llvm.round.f128", genF128F128FuncType,
-     genMathOp<mlir::LLVM::RoundOp>},
     {"atan", "atanf", genF32F32FuncType, genMathOp<mlir::math::AtanOp>},
     {"atan", "atan", genF64F64FuncType, genMathOp<mlir::math::AtanOp>},
     {"atan2", "atan2f", genF32F32F32FuncType, genMathOp<mlir::math::Atan2Op>},

diff  --git a/flang/test/Lower/Intrinsics/aint.f90 b/flang/test/Lower/Intrinsics/aint.f90
index 1d58a0359f3a4..374a5f961e92e 100644
--- a/flang/test/Lower/Intrinsics/aint.f90
+++ b/flang/test/Lower/Intrinsics/aint.f90
@@ -39,16 +39,8 @@ subroutine aint_test_real10(a, b)
   b = aint(a)
 end subroutine
 
-! CHECK-LABEL: func.func @_QPaint_test_real16(
-! CHECK-SAME:                                 %[[VAL_0:.*]]: !fir.ref<f128> {fir.bindc_name = "a"},
-! CHECK-SAME:                                 %[[VAL_1:.*]]: !fir.ref<f128> {fir.bindc_name = "b"}) {
-! CHECK:         %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f128>
-! CHECK:         %[[VAL_3:.*]] = fir.call @llvm.trunc.f128(%[[VAL_2]]) : (f128) -> f128
-! CHECK:         fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f128>
-! CHECK:         return
-! CHECK:       }
-
-subroutine aint_test_real16(a, b)
-  real(16) :: a, b
-  b = aint(a)
-end subroutine
+! TODO: wait until fp128 is supported well in llvm.trunc
+!subroutine aint_test_real16(a, b)
+!  real(16) :: a, b
+!  b = aint(a)
+!end subroutine

diff  --git a/flang/test/Lower/Intrinsics/anint.f90 b/flang/test/Lower/Intrinsics/anint.f90
index fb9d446b647aa..03b376e2605c7 100644
--- a/flang/test/Lower/Intrinsics/anint.f90
+++ b/flang/test/Lower/Intrinsics/anint.f90
@@ -42,16 +42,8 @@ subroutine anint_test_real10(a, b)
   b = anint(a)
 end subroutine
 
-! CHECK-LABEL: func.func @_QPanint_test_real16(
-! CHECK-SAME:                                  %[[VAL_0:.*]]: !fir.ref<f128> {fir.bindc_name = "a"},
-! CHECK-SAME:                                  %[[VAL_1:.*]]: !fir.ref<f128> {fir.bindc_name = "b"}) {
-! CHECK:         %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f128>
-! CHECK:         %[[VAL_3:.*]] = "llvm.intr.round"(%[[VAL_2]]) : (f128) -> f128
-! CHECK:         fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f128>
-! CHECK:         return
-! CHECK:       }
-
-subroutine anint_test_real16(a, b)
-  real(16) :: a, b
-  b = anint(a)
-end subroutine
+! TODO: wait until fp128 is supported well in llvm.round
+!subroutine anint_test_real16(a, b)
+!  real(16) :: a, b
+!  b = anint(a)
+!end subroutine

diff  --git a/flang/test/Lower/math-lowering.f90 b/flang/test/Lower/math-lowering.f90
index 3514a76f3bf32..7a74068d780fb 100644
--- a/flang/test/Lower/math-lowering.f90
+++ b/flang/test/Lower/math-lowering.f90
@@ -85,13 +85,11 @@ function test_real10(x)
 ! ALL-LABEL: @_QPtest_real10
 ! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f80({{%[A-Za-z0-9._]+}}) : (f80) -> f80
 
-function test_real16(x)
-  real(16) :: x, test_real16
-  test_real16 = aint(x)
-end function
-
-! ALL-LABEL: @_QPtest_real16
-! ALL: {{%[A-Za-z0-9._]+}} = fir.call @llvm.trunc.f128({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+! TODO: wait until fp128 is supported well in llvm.trunc
+!function test_real16(x)
+!  real(16) :: x, test_real16
+!  test_real16 = aint(x)
+!end function
 
 //--- anint.f90
 ! RUN: bbc -emit-fir %t/anint.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/anint.f90
@@ -131,15 +129,11 @@ function test_real10(x)
 ! RELAXED: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f80) -> f80
 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f80({{%[A-Za-z0-9._]+}}) : (f80) -> f80
 
-function test_real16(x)
-  real(16) :: x, test_real16
-  test_real16 = anint(x)
-end function
-
-! ALL-LABEL: @_QPtest_real16
-! FAST: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f128) -> f128
-! RELAXED: {{%[A-Za-z0-9._]+}} = "llvm.intr.round"({{%[A-Za-z0-9._]+}}) : (f128) -> f128
-! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f128({{%[A-Za-z0-9._]+}}) : (f128) -> f128
+! TODO: wait until fp128 is supported well in llvm.round
+!function test_real16(x)
+!  real(16) :: x, test_real16
+!  test_real16 = anint(x)
+!end function
 
 //--- atan.f90
 ! RUN: bbc -emit-fir %t/atan.f90 -o - --math-runtime=fast | FileCheck --check-prefixes=ALL,FAST %t/atan.f90


        


More information about the flang-commits mailing list