File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -8233,10 +8233,10 @@ mlir::Value IntrinsicLibrary::genTanpi(mlir::Type resultType,
8233
8233
mlir::MLIRContext *context = builder.getContext ();
8234
8234
mlir::FunctionType ftype =
8235
8235
mlir::FunctionType::get (context, {resultType}, {args[0 ].getType ()});
8236
- llvm::APFloat pi = llvm::APFloat (llvm::numbers::pi);
8237
- mlir::Value dfactor =
8238
- builder. createRealConstant (loc, mlir::Float64Type::get (context), pi );
8239
- mlir::Value factor = builder.createConvert (loc, args[ 0 ]. getType (), dfactor );
8236
+ llvm::APFloat pi =
8237
+ llvm::APFloat (llvm::cast< mlir::FloatType>(resultType). getFloatSemantics (),
8238
+ llvm::numbers::pis );
8239
+ mlir::Value factor = builder.createRealConstant (loc, resultType, pi );
8240
8240
mlir::Value arg = mlir::arith::MulFOp::create (builder, loc, args[0 ], factor);
8241
8241
return getRuntimeCallGenerator (" tan" , ftype)(builder, loc, {arg});
8242
8242
}
Original file line number Diff line number Diff line change
1
+ ! REQUIRES: flang-supports-f128-math
1
2
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s --check-prefixes="CHECK"
2
3
3
4
function test_real4 (x )
@@ -6,8 +7,7 @@ function test_real4(x)
6
7
end function
7
8
8
9
! CHECK-LABEL: @_QPtest_real4
9
- ! CHECK: %[[dfactor:.*]] = arith.constant 3.1415926535897931 : f64
10
- ! CHECK: %[[factor:.*]] = fir.convert %[[dfactor]] : (f64) -> f32
10
+ ! CHECK: %[[factor:.*]] = arith.constant 3.14159274 : f32
11
11
! CHECK: %[[mul:.*]] = arith.mulf %{{.*}}, %[[factor]] fastmath<contract> : f32
12
12
! CHECK: %[[tan:.*]] = math.tan %[[mul]] fastmath<contract> : f32
13
13
@@ -20,3 +20,13 @@ function test_real8(x)
20
20
! CHECK: %[[dfactor:.*]] = arith.constant 3.1415926535897931 : f64
21
21
! CHECK: %[[mul:.*]] = arith.mulf %{{.*}}, %[[dfactor]] fastmath<contract> : f64
22
22
! CHECK: %[[tan:.*]] = math.tan %[[mul]] fastmath<contract> : f64
23
+
24
+ function test_real16 (x )
25
+ real (16 ) :: x, test_real16
26
+ test_real16 = tanpi(x)
27
+ end function
28
+
29
+ ! CHECK-LABEL: @_QPtest_real16
30
+ ! CHECK: %[[factor:.*]] = arith.constant 3.141592653589793238462643383279{{.*}} : f128
31
+ ! CHECK: %[[mul:.*]] = arith.mulf %{{.*}}, %[[factor]] fastmath<contract> : f128
32
+ ! CHECK: %[[tan:.*]] = fir.call @_FortranATanF128(%[[mul]]) fastmath<contract> : (f128) -> f128
You can’t perform that action at this time.
0 commit comments