This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gomp] Don't optimize out clauses that are actually needed (PR fortran/25162)


Hi!

As shown by the testcase below, if the routine with the clauses didn't
reference a variable anywhere except in omp clauses, it wouldn't be emitted
into GIMPLE at all, eventhough e.g. for COPYIN/COPYPRIVATE it really can't
be optimized out in such cases.
The middle-end now does a good job of killing unneeded clauses, so I think
it is ok to mark all such symbols as referenced.
Regtested on x86_64-linux, committed.

2005-11-30  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/25162
	* openmp.c (gfc_match_omp_variable_list): Call gfc_set_sym_referenced
	on all symbols added to the namelist.

	* testsuite/libgomp.fortran/pr25162.f: New test.

--- gcc/fortran/openmp.c.jj	2005-11-18 14:54:33.000000000 +0100
+++ gcc/fortran/openmp.c	2005-11-30 13:37:21.000000000 +0100
@@ -103,6 +103,7 @@ gfc_match_omp_variable_list (const char 
       switch (m)
 	{
 	case MATCH_YES:
+	  gfc_set_sym_referenced (sym);
 	  p = gfc_get_namelist ();
 	  if (head == NULL)
 	    head = tail = p;
@@ -136,6 +137,7 @@ gfc_match_omp_variable_list (const char 
 	}
       for (sym = st->n.common->head; sym; sym = sym->common_next)
 	{
+	  gfc_set_sym_referenced (sym);
 	  p = gfc_get_namelist ();
 	  if (head == NULL)
 	    head = tail = p;
--- libgomp/testsuite/libgomp.fortran/pr25162.f.jj	2005-11-30 13:12:13.000000000 +0100
+++ libgomp/testsuite/libgomp.fortran/pr25162.f	2005-11-30 13:08:59.000000000 +0100
@@ -0,0 +1,39 @@
+C PR fortran/25162
+C { dg-do run }
+      PROGRAM PR25162
+      CALL TEST1
+      CALL TEST2
+      END
+      SUBROUTINE TEST1
+      DOUBLE PRECISION BPRIM
+      COMMON /TESTCOM/ BPRIM(100)
+C$OMP THREADPRIVATE(/TESTCOM/)
+      INTEGER I
+      DO I = 1, 100
+         BPRIM( I ) = DBLE( I )
+      END DO
+      RETURN
+      END
+      SUBROUTINE TEST2
+      DOUBLE PRECISION BPRIM
+      COMMON /TESTCOM/ BPRIM(100)
+C$OMP THREADPRIVATE(/TESTCOM/)
+      INTEGER I, IDUM(50)
+      DO I = 1, 50
+         IDUM(I) = I
+      END DO
+C$OMP PARALLEL COPYIN(/TESTCOM/) NUM_THREADS(4)
+      CALL TEST3
+C$OMP END PARALLEL
+      RETURN
+      END
+      SUBROUTINE TEST3
+      DOUBLE PRECISION BPRIM
+      COMMON /TESTCOM/ BPRIM(100)
+C$OMP THREADPRIVATE(/TESTCOM/)
+      INTEGER K
+      DO K = 1, 10
+         IF (K.NE.BPRIM(K)) CALL ABORT
+      END DO
+      RETURN
+      END

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]