This is the mail archive of the 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]

[match-and-simplify] fix incorrect code-gen in 'for' pattern

genmatch generates incorrect code for following (artificial) pattern:

(for op (plus)
      op2 (op)
    (op @x @y)
    (op2 @x @y)

generated gimple code:
'op' is not replaced in the generated code on line 33:
*res_code = op;

I think it would be a better idea to make op2 iterate over same set
of operators (op2->substitutes = op->substitutes).
I have attached patch for the same.
Bootstrap + testing in progress on x86_64-unknown-linux-gnu.
OK for trunk after bootstrap+testing completes ?

I wonder if we really need is_oper_list flag in user_id ?
We can determine if user_id is an operator list
if user_id::substitutes is not empty ?
That will lose the ability to distinguish between user-defined operator
list and list-iterator in for like op/op2, but I suppose we (so far) don't
need to distinguish between them ?

Index: genmatch.c
--- genmatch.c	(revision 223225)
+++ genmatch.c	(working copy)
@@ -3329,7 +3329,7 @@
 		      "others with arity %d", oper, idb->nargs, arity);
 	  user_id *p = dyn_cast<user_id *> (idb);
-	  if (p && p->is_oper_list)
+	  if (p && !p->substitutes.is_empty()) // p is either user-defined operator list or a list iterator
 	    op->substitutes.safe_splice (p->substitutes);
 	    op->substitutes.safe_push (idb);

Attachment: ChangeLog
Description: Binary data

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