From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 85CF53858D35 for ; Tue, 18 Apr 2023 10:38:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85CF53858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4ec8133c698so9693820e87.0 for ; Tue, 18 Apr 2023 03:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681814311; x=1684406311; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ndsxgrfo32KXexTodIXTxSVWAhMDJIAq3z3i4HQNv/c=; b=TvjcwFTHAD51YfBYOKlCkvtaB7sz3xD2vQyVgVX4dYE9XEMvsbrV+lFAt7zghnXCqq yVaTeMoKz1KLSOD2bI0SOsyfvVrecYcDUIRclYuoQ3IoQJDQ6TMDi3R3HRf13nfvcde+ 6+9YOF2KXMKhXp/J1dFs+xPinie8wkvYoQ6rihfRxVyCshDY9dO9wej36YzNCPleNTxr MZxYP7kwK6cKVp6wRNaR3K5X5dWtjnYUovsb+vzey2krktzkae15dbQqF3QATfaMOfSL e7FIgQEBJr/GP60njBxMTEjyvecmipCBLYe3TRtZz4ypbSGM7ovgw156tIH8dG39d3kH uFPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681814311; x=1684406311; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ndsxgrfo32KXexTodIXTxSVWAhMDJIAq3z3i4HQNv/c=; b=LihJj9IyAz+LN/VVOJ+2xh93d24MNbZBqJ+YFs0GiC0Ea3NP9HCfWvCWCwJbnYxc7O LbUgnYeuSUPyQNtPx5g+qm8STAiel+KcxugrD2rmU+YldkX8iT/pticzVrP1PwP6mqKL keUDmwruJRMnvyBxjCheQv3+XMveg6c/BiYXBE27QYCdjBoD5RazK4+DxZf1o+UpC6ez 8xAGvu7lBckpejOh76x3VcfiaMlAy33R3/zJQ/QXpBFUgpRhr8Cm6poSzzlbWn2lKLoY Q6ZUfaP5IBjrvsAhIfrrnZubjDk4u0S/4pAtJ+CVe0ujr9PA4DQz0uyeS8cyJ4PCwjuL 5gzA== X-Gm-Message-State: AAQBX9eHoh6wr4C4Xl+85EPl8qzBlTpvpj4cvzGXyUzlS65fzLlZRouQ Tk/MXOViuCVy12fp6xfwbKQOUfgMBMIwvNLOywY= X-Google-Smtp-Source: AKy350aO3Uhfaiey1u8fBa7qTBwdG9BVyzYAxqzJkzTi7l3VHm2q4hDV8Kt8dkU4nwP26RDOhuvJr8eaUFaeqQk3z50= X-Received: by 2002:a05:6512:78:b0:4ec:8e1e:60c7 with SMTP id i24-20020a056512007800b004ec8e1e60c7mr3289329lfo.4.1681814310808; Tue, 18 Apr 2023 03:38:30 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Tue, 18 Apr 2023 12:38:18 +0200 Message-ID: Subject: Re: [PATCH 1/3]middle-end match.pd: don't emit label if not needed To: Tamar Christina Cc: gcc-patches@gcc.gnu.org, nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Apr 18, 2023 at 12:21=E2=80=AFPM Tamar Christina via Gcc-patches wrote: > > Hi All, > > This is a small QoL codegen improvement for match.pd to not emit labels w= hen > they are not needed. The codegen is nice and there is a small (but consi= stent) > improvement in compile time. > > Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. > > Ok for master? OK. Btw - how many labels does this remove? (just wc -l the generated file= s?) Richard. > Thanks, > Tamar > > gcc/ChangeLog: > > PR bootstrap/84402 > * genmatch.cc (dt_simplify::gen_1): Only emit labels if used. > > --- inline copy of patch -- > diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc > index 4fab4135347c43d95546a7df0bb1c4d074937288..638606b2502f640e59527fc5a= 0b23fa3bedd0cee 100644 > --- a/gcc/genmatch.cc > +++ b/gcc/genmatch.cc > @@ -3352,6 +3352,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimpl= e, operand *result) > char local_fail_label[256]; > snprintf (local_fail_label, 256, "next_after_fail%u", ++fail_label_cnt= ); > fail_label =3D local_fail_label; > + bool needs_label =3D false; > > /* Analyze captures and perform early-outs on the incoming arguments > that cover cases we cannot handle. */ > @@ -3366,6 +3367,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimpl= e, operand *result) > fprintf_indent (f, indent, > "if (TREE_SIDE_EFFECTS (_p%d)) goto %s;\n= ", > i, fail_label); > + needs_label =3D true; > if (verbose >=3D 1) > warning_at (as_a (s->match)->ops[i]->location, > "forcing toplevel operand to have no " > @@ -3381,6 +3383,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimpl= e, operand *result) > fprintf_indent (f, indent, > "if (TREE_SIDE_EFFECTS (captures[%d])) " > "goto %s;\n", i, fail_label); > + needs_label =3D true; > if (verbose >=3D 1) > warning_at (cinfo.info[i].c->location, > "forcing captured operand to have no " > @@ -3423,7 +3426,10 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimp= le, operand *result) > } > > if (s->kind =3D=3D simplify::SIMPLIFY) > - fprintf_indent (f, indent, "if (UNLIKELY (!dbg_cnt (match))) goto %s= ;\n", fail_label); > + { > + fprintf_indent (f, indent, "if (UNLIKELY (!dbg_cnt (match))) goto = %s;\n", fail_label); > + needs_label =3D true; > + } > > fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & T= DF_FOLDING))) " > "fprintf (dump_file, \"%s ", > @@ -3496,9 +3502,12 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimp= le, operand *result) > "res_op->resimplify (%s, valueize);\n", > !e->force_leaf ? "lseq" : "NULL"); > if (e->force_leaf) > - fprintf_indent (f, indent, > - "if (!maybe_push_res_to_seq (res_op, NULL= )) " > - "goto %s;\n", fail_label); > + { > + fprintf_indent (f, indent, > + "if (!maybe_push_res_to_seq (res_op, NU= LL)) " > + "goto %s;\n", fail_label); > + needs_label =3D true; > + } > } > } > else if (result->type =3D=3D operand::OP_CAPTURE > @@ -3554,9 +3563,12 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimp= le, operand *result) > continue; > if (cinfo.info[i].result_use_count > > cinfo.info[i].match_use_count) > - fprintf_indent (f, indent, > - "if (! tree_invariant_p (captures[%d]))= " > - "goto %s;\n", i, fail_label); > + { > + fprintf_indent (f, indent, > + "if (! tree_invariant_p (captures[%d]= )) " > + "goto %s;\n", i, fail_label); > + needs_label =3D true; > + } > } > for (unsigned j =3D 0; j < e->ops.length (); ++j) > { > @@ -3607,6 +3619,7 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimpl= e, operand *result) > { > fprintf_indent (f, indent, "if (!_r)\n"); > fprintf_indent (f, indent, " goto %s;\n", fail_lab= el); > + needs_label =3D true; > } > } > } > @@ -3647,7 +3660,8 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimpl= e, operand *result) > } > indent -=3D 2; > fprintf_indent (f, indent, "}\n"); > - fprintf (f, "%s:;\n", fail_label); > + if (needs_label) > + fprintf (f, "%s:;\n", fail_label); > fail_label =3D NULL; > } > > > > > > --