diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp index d67eebdd8c93..b4d4d84d4c2e 100644 --- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp +++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp @@ -1198,11 +1198,11 @@ static constexpr MathOperation mathOperations[] = { {"aint", RTNAME_STRING(TruncF128), FuncTypeReal16Real16, genLibF128Call}, // llvm.round behaves the same way as libm's round. {"anint", "llvm.round.f32", genFuncType, Ty::Real<4>>, - genMathOp}, + genMathOp}, {"anint", "llvm.round.f64", genFuncType, Ty::Real<8>>, - genMathOp}, + genMathOp}, {"anint", "llvm.round.f80", genFuncType, Ty::Real<10>>, - genMathOp}, + genMathOp}, {"anint", RTNAME_STRING(RoundF128), FuncTypeReal16Real16, genLibF128Call}, {"asin", "asinf", genFuncType, Ty::Real<4>>, genMathOp}, diff --git a/flang/test/Lower/Intrinsics/anint.f90 b/flang/test/Lower/Intrinsics/anint.f90 index a7b24648ca0b..2ea24b840849 100644 --- a/flang/test/Lower/Intrinsics/anint.f90 +++ b/flang/test/Lower/Intrinsics/anint.f90 @@ -6,7 +6,7 @@ ! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[VAL_0_b]] ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_1_b]] ! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]]#0 : !fir.ref -! CHECK: %[[VAL_3:.*]] = llvm.intr.round(%[[VAL_2]]) : (f32) -> f32 +! CHECK: %[[VAL_3:.*]] = math.round %[[VAL_2]] fastmath : f32 ! CHECK: hlfir.assign %[[VAL_3]] to %[[VAL_1]]#0 : f32, !fir.ref ! CHECK: return ! CHECK: } @@ -17,7 +17,7 @@ subroutine anint_test(a, b) end subroutine ! CHECK-LABEL: func.func @_QPanint_test_real8( -! CHECK: llvm.intr.round(%{{.*}}) : (f64) -> f64 +! CHECK: math.round %{{.*}} fastmath : f64 subroutine anint_test_real8(a, b) real(8) :: a, b @@ -25,7 +25,7 @@ subroutine anint_test_real8(a, b) end subroutine ! CHECK-KIND10-LABEL: func.func @_QPanint_test_real10( -! CHECK-KIND10: llvm.intr.round(%{{.*}}) : (f80) -> f80 +! CHECK-KIND10: math.round %{{.*}} fastmath : f80 subroutine anint_test_real10(a, b) integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10) diff --git a/flang/test/Lower/math-lowering/anint.f90 b/flang/test/Lower/math-lowering/anint.f90 index f39009de7e4f..866986bbbcdb 100644 --- a/flang/test/Lower/math-lowering/anint.f90 +++ b/flang/test/Lower/math-lowering/anint.f90 @@ -13,8 +13,8 @@ function test_real4(x) end function ! ALL-LABEL: @_QPtest_real4 -! FAST: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f32) -> f32 -! RELAXED: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f32) -> f32 +! FAST: {{%[A-Za-z0-9._]+}} = math.round {{%[A-Za-z0-9._]+}} fastmath : f32 +! RELAXED: {{%[A-Za-z0-9._]+}} = math.round {{%[A-Za-z0-9._]+}} fastmath : f32 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f32({{%[A-Za-z0-9._]+}}) {{.*}}: (f32) -> f32 function test_real8(x) @@ -23,8 +23,8 @@ function test_real8(x) end function ! ALL-LABEL: @_QPtest_real8 -! FAST: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f64) -> f64 -! RELAXED: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f64) -> f64 +! FAST: {{%[A-Za-z0-9._]+}} = math.round {{%[A-Za-z0-9._]+}} fastmath : f64 +! RELAXED: {{%[A-Za-z0-9._]+}} = math.round {{%[A-Za-z0-9._]+}} fastmath : f64 ! PRECISE: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f64({{%[A-Za-z0-9._]+}}) {{.*}}: (f64) -> f64 function test_real10(x) @@ -34,8 +34,8 @@ function test_real10(x) end function ! ALL-KIND10-LABEL: @_QPtest_real10 -! FAST-KIND10: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f80) -> f80 -! RELAXED-KIND10: {{%[A-Za-z0-9._]+}} = llvm.intr.round({{%[A-Za-z0-9._]+}}) : (f80) -> f80 +! FAST-KIND10: {{%[A-Za-z0-9._]+}} = math.round {{%[A-Za-z0-9._]+}} fastmath : f80 +! RELAXED-KIND10: {{%[A-Za-z0-9._]+}} = math.round {{%[A-Za-z0-9._]+}} fastmath : f80 ! PRECISE-KIND10: {{%[A-Za-z0-9._]+}} = fir.call @llvm.round.f80({{%[A-Za-z0-9._]+}}) {{.*}}: (f80) -> f80 ! TODO: wait until fp128 is supported well in llvm.round