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 @@ -3684,10 +3684,10 @@ mlir::Value IntrinsicLibrary::genCospi(mlir::Type resultType,
3684
3684
mlir::MLIRContext *context = builder.getContext ();
3685
3685
mlir::FunctionType ftype =
3686
3686
mlir::FunctionType::get (context, {resultType}, {args[0 ].getType ()});
3687
- llvm::APFloat pi = llvm::APFloat (llvm::numbers::pi);
3688
- mlir::Value dfactor =
3689
- builder. createRealConstant (loc, mlir::Float64Type::get (context), pi );
3690
- mlir::Value factor = builder.createConvert (loc, args[ 0 ]. getType (), dfactor );
3687
+ llvm::APFloat pi =
3688
+ llvm::APFloat (llvm::cast< mlir::FloatType>(resultType). getFloatSemantics (),
3689
+ llvm::numbers::pis );
3690
+ mlir::Value factor = builder.createRealConstant (loc, resultType, pi );
3691
3691
mlir::Value arg = mlir::arith::MulFOp::create (builder, loc, args[0 ], factor);
3692
3692
return getRuntimeCallGenerator (" cos" , ftype)(builder, loc, {arg});
3693
3693
}
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: %[[cos:.*]] = math.cos %[[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: %[[cos:.*]] = math.cos %[[mul]] fastmath<contract> : f64
23
+
24
+ function test_real16 (x )
25
+ real (16 ) :: x, test_real16
26
+ test_real16 = cospi(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: %[[cos:.*]] = fir.call @_FortranACosF128(%[[mul]]) fastmath<contract> : (f128) -> f128
You can’t perform that action at this time.
0 commit comments