Patchwork [Fortran] PR54463 - fix -fexternal-matmul with -fdefault-real-8

login
register
mail settings
Submitter Tobias Burnus
Date Sept. 5, 2012, 9:55 p.m.
Message ID <5047CA6A.8020808@net-b.de>
Download mbox | patch
Permalink /patch/181964/
State New
Headers show

Comments

Tobias Burnus - Sept. 5, 2012, 9:55 p.m.
Rather obvious fix.

Build on x86-64-linux.
OK for the trunk when regtesting has succeeded?

Tobias
Steve Kargl - Sept. 5, 2012, 9:59 p.m.
On Wed, Sep 05, 2012 at 11:55:54PM +0200, Tobias Burnus wrote:
> Rather obvious fix.
> 
> Build on x86-64-linux.
> OK for the trunk when regtesting has succeeded?
> 

Yes.

Patch

2012-09-06  Tobias Burnus

	PR fortran/54463
	* trans-intrinsic.c (gfc_conv_intrinsic_funcall): Fix matmul
	call to BLAS if the default-kind has been promoted.

2012-09-06  Tobias Burnus

	PR fortran/54463
	* gfortran.dg/promotion_2.f90: New.

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index add4baa..4b268b3 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -2362,21 +2362,20 @@  gfc_conv_intrinsic_funcall (gfc_se * se, gfc_expr * expr)
 
       if (gfc_option.flag_external_blas
 	  && (sym->ts.type == BT_REAL || sym->ts.type == BT_COMPLEX)
-	  && (sym->ts.kind == gfc_default_real_kind
-	      || sym->ts.kind == gfc_default_double_kind))
+	  && (sym->ts.kind == 4 || sym->ts.kind == 8))
 	{
 	  tree gemm_fndecl;
 
 	  if (sym->ts.type == BT_REAL)
 	    {
-	      if (sym->ts.kind == gfc_default_real_kind)
+	      if (sym->ts.kind == 4)
 		gemm_fndecl = gfor_fndecl_sgemm;
 	      else
 		gemm_fndecl = gfor_fndecl_dgemm;
 	    }
 	  else
 	    {
-	      if (sym->ts.kind == gfc_default_real_kind)
+	      if (sym->ts.kind == 4)
 		gemm_fndecl = gfor_fndecl_cgemm;
 	      else
 		gemm_fndecl = gfor_fndecl_zgemm;
--- /dev/null	2012-09-03 07:48:56.919718426 +0200
+++ gcc/gcc/testsuite/gfortran.dg/promotion_2.f90	2012-09-05 19:52:17.000000000 +0200
@@ -0,0 +1,16 @@ 
+! { dg-do compile }
+! { dg-options "-fdefault-real-8 -fexternal-blas -fdump-tree-original" }
+!
+! PR fortran/54463
+!
+! Contributed by Simon Reinhardt
+!
+program test
+  implicit none
+  real, dimension(3,3) :: A
+  A = matmul(A,A)
+end program test
+
+! { dg-final { scan-tree-dump-times "sgemm_" 0 "original" } }
+! { dg-final { scan-tree-dump-times "dgemm_" 1 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }