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] PR35339 Optimize implied do loops in io statements


On Sat, Jun 03, 2017 at 09:25:31AM -0700, Jerry DeLisle wrote:
> On 06/03/2017 06:48 AM, Nicolas Koenig wrote:
> > Hello everyone,
> > 
> > here is a version of the patch that includes a workaround for PR 80960. I have
> > also included a separate test case for the failure that Dominique detected. The
> > style issues should be fixed.
> > 
> > Regression-tested. OK for trunk?
> > 
> 
> Yes, OK.

There still are plenty of coding-style issues (see below).
Can you please rectify them before committing?

Also you change gfc-internals.texi without a ChangeLog entry. I guess
this was an accident?

thanks,

$ contrib/check_GNU_style.sh /tmp/p9.diff 

Blocks of 8 spaces should be replaced with tabs.
40:+        break;
55:+        return false;
61:+        {
64:+              curr->block->next = NULL;
65:+              gfc_free_statements(curr);
70:+        }
92:+          || ref->u.ar.dimen_type[i] != DIMEN_ELEMENT)
93:+        return false;
98:+        {
111:+              iters[i] = stack_top->iter;
116:+        case EXPR_CONSTANT:
120:+          switch (start->value.op.op)
125:+	        std::swap(start->value.op.op1, start->value.op.op2);
130:+	          || start->value.op.op1->ref)
131:+	        return false;
132:+              if (!stack_top || !stack_top->iter 
135:+	        return false;
146:+        }
160:+        continue;
163:+        {
174:+          break;
214:+        {
215:+          curr->next = prev->next->next;
216:+          prev->next = curr;
219:+        {
220:+          curr->next = stack_top->code->block->next->next->next;
253:+        {
254:+          first.prev = &write;
260:+        }

Trailing whitespace.
18:+   
20:+     
22:+     
25:+static bool 
28:+  gfc_code *curr; 
44:+       
94:+      
106:+	  if (!stack_top || !stack_top->iter 
108:+	    iters[i] = NULL; 
128:+	      if ((start->value.op.op1->expr_type!= EXPR_VARIABLE 
132:+              if (!stack_top || !stack_top->iter 
133:+		  || stack_top->iter->var->symtree 
136:+	      iters[i] = stack_top->iter; 
152:+  new_e->rank = future_rank; 
176:+	  new_e->ref->u.ar.dimen_type[i] = DIMEN_RANGE; 
218:+      else 
244:+  
249:+  

Dot, space, space, new sentence.
17:+   optimize by replacing do loops with their analog array slices. For example:

There should be exactly one space between function name and parenthesis.
26:+traverse_io_block(gfc_code *code, bool *has_reached, gfc_code *prev)
60:+      if (traverse_io_block(curr->block->next, has_reached, prev))
65:+              gfc_free_statements(curr);
74:+  gcc_assert(curr->op == EXEC_TRANSFER);
96:+      gfc_simplify_expr(start, 0);
125:+	        std::swap(start->value.op.op1, start->value.op.op2);
126:+	      gcc_fallthrough();
150:+  new_e = gfc_copy_expr(curr->expr1);
154:+    new_e->shape = gfc_get_shape(new_e->rank);
165:+	  gfc_internal_error("bad expression");
170:+	  gfc_free_expr(new_e->ref->u.ar.start[i]);
171:+	  new_e->ref->u.ar.start[i] = gfc_copy_expr(iters[i]->start);
172:+	  new_e->ref->u.ar.end[i] = gfc_copy_expr(iters[i]->end);
173:+	  new_e->ref->u.ar.stride[i] = gfc_copy_expr(iters[i]->step);
178:+	  gfc_free_expr(new_e->ref->u.ar.start[i]);
179:+	  expr = gfc_copy_expr(start);
180:+	  expr->value.op.op1 = gfc_copy_expr(iters[i]->start);
182:+	  gfc_simplify_expr(new_e->ref->u.ar.start[i], 0);
183:+	  expr = gfc_copy_expr(start);
184:+	  expr->value.op.op1 = gfc_copy_expr(iters[i]->end);
186:+	  gfc_simplify_expr(new_e->ref->u.ar.end[i], 0);
187:+	  switch(start->value.op.op)
191:+	      new_e->ref->u.ar.stride[i] = gfc_copy_expr(iters[i]->step);
194:+	      expr = gfc_copy_expr(start);
195:+	      expr->value.op.op1 = gfc_copy_expr(iters[i]->step);
197:+	      gfc_simplify_expr(new_e->ref->u.ar.stride[i], 0);
200:+	      gfc_internal_error("bad op");
204:+	  gfc_internal_error("bad expression");
258:+	  traverse_io_block((*curr)->block->next, &b, prev);

> 
> Thanks for the work.
> 
> Jerry


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