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]

Re: [patch, fortran] Some more TRIM optimizations


I wrote:

Hello world,

the attached patch extends removing trailing TRIMs in assignments for
cases like a // trim(b). Regression-tested. OK for trunk?

Thomas

This time with the test case corrected (cleanup of the *.original file) and a more meaningful Subject line.

OK?

Thomas

2011-05-06 Thomas König <tkoenig@gcc.gnu.org>

        * frontend-passes.c (optimize_assignment): Follow chains
        of concatenation operators to the end for removing trailing
        TRIMS for assignments.

2011-05-06 Thomas König <tkoenig@gcc.gnu.org>

* gfortran.dg/trim_optimize_7.f90: New test.
Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 174391)
+++ frontend-passes.c	(Arbeitskopie)
@@ -500,6 +500,14 @@ optimize_assignment (gfc_code * c)
 
   if (lhs->ts.type == BT_CHARACTER)
     {
+      /* Check for a // b // trim(c).  Looping is probably not
+	 necessary because the parser usually generates
+	 (// (// a b ) trim(c) ) , but better safe than sorry.  */
+
+      while (rhs->expr_type == EXPR_OP
+	     && rhs->value.op.op == INTRINSIC_CONCAT)
+	rhs = rhs->value.op.op2;
+
       if (rhs->expr_type == EXPR_FUNCTION &&
 	  rhs->value.function.isym &&
 	  rhs->value.function.isym->id == GFC_ISYM_TRIM)

Attachment: trim_optimize_7.f90
Description: Text document


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