From patchwork Fri May 15 22:16:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 48578 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A6FC72121F for ; Fri, 15 May 2015 22:16:44 +0000 (UTC) Received: by wgin8 with SMTP id n8sf34072649wgi.0 for ; Fri, 15 May 2015 15:16:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:mime-version:date:message-id:subject:from:to :content-type:x-original-sender:x-original-authentication-results; bh=jQY+f50FLgisZWjRjo80Gi/MzKKpg1n2vGXN8EkIgGk=; b=bprYOrOlGZJJ4Z+n+z+uqdWaf9aIj1te7TBqDPkDjXsMTBh7t+WG2+l79gW87RI9ys mptjP5gImXjk/Q/XtRYcohbEfGF3oxXWGI1DP06FIRCRgkpDmAHZz2sPCdnw6iBql5RQ Om8x/Q4cvjBcsc12+w59i4JNo2sAzGzvKYjdylwUIMFGUJGydoA2ZccylXRQ/rzlv6Ov opalLXjocaSzN+kAFNqVaGIuMKFO2PHug4/qNZrMWk2hZkQyKTApuKuK0kfSoE2jibpb RjNcOXegRPYCz6fFuaRxXT0mBTK678GRE1KJIj91AAJFNxAokWFjc0dO1qF3FEMD0M38 nTxg== X-Gm-Message-State: ALoCoQlVpL2UQTpZEIf8P32kn8HnyGbC1MGCOUggyIlEEKgi0zQoap8pGmrrhd7UdrE+fwadyRze X-Received: by 10.112.171.41 with SMTP id ar9mr8494749lbc.24.1431728203796; Fri, 15 May 2015 15:16:43 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.137 with SMTP id o9ls531793lal.16.gmail; Fri, 15 May 2015 15:16:43 -0700 (PDT) X-Received: by 10.152.2.38 with SMTP id 6mr8907165lar.80.1431728203575; Fri, 15 May 2015 15:16:43 -0700 (PDT) Received: from mail-la0-x22e.google.com (mail-la0-x22e.google.com. [2a00:1450:4010:c03::22e]) by mx.google.com with ESMTPS id xd3si1887436lbb.166.2015.05.15.15.16.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 May 2015 15:16:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22e as permitted sender) client-ip=2a00:1450:4010:c03::22e; Received: by labbd9 with SMTP id bd9so141445284lab.2 for ; Fri, 15 May 2015 15:16:43 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr8954333lab.35.1431728203017; Fri, 15 May 2015 15:16:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2329997lbb; Fri, 15 May 2015 15:16:41 -0700 (PDT) X-Received: by 10.67.1.98 with SMTP id bf2mr22430751pad.33.1431728200867; Fri, 15 May 2015 15:16:40 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id vx6si4381008pab.220.2015.05.15.15.16.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 May 2015 15:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-398026-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 44920 invoked by alias); 15 May 2015 22:16:26 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 44911 invoked by uid 89); 15 May 2015 22:16:26 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f47.google.com Received: from mail-la0-f47.google.com (HELO mail-la0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 15 May 2015 22:16:24 +0000 Received: by lagv1 with SMTP id v1so141214400lag.3 for ; Fri, 15 May 2015 15:16:21 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.78.105 with SMTP id a9mr8703774lbx.70.1431728181379; Fri, 15 May 2015 15:16:21 -0700 (PDT) Received: by 10.25.205.146 with HTTP; Fri, 15 May 2015 15:16:21 -0700 (PDT) Date: Sat, 16 May 2015 03:46:21 +0530 Message-ID: Subject: [match-and-simplify] fix incorrect code-gen in 'for' pattern From: Prathamesh Kulkarni To: Richard Biener , gcc Patches X-IsSubscribed: yes X-Original-Sender: prathamesh.kulkarni@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::22e as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Hi, genmatch generates incorrect code for following (artificial) pattern: (for op (plus) op2 (op) (simplify (op @x @y) (op2 @x @y) generated gimple code: http://pastebin.com/h1uau9qB '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 ? Thanks, Prathamesh 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 (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); else op->substitutes.safe_push (idb);