From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id C22F03858D28; Tue, 2 Apr 2024 07:06:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C22F03858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C22F03858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712041581; cv=none; b=usTTFNkd5qlkBTQMgD+3tcFoOTZR8nsVxPJPaxYrCRO4cEX2SmE9Dfb/G5biS/8ZsBiofg/emkbeHEe7SJ6Ke2gDZjMJzVFW2fkANE+XqZpsDJbqndlVADyLwVzpqoOYppHnFl63skWluv950b4QweKcNqAI+G3wzs4FUmZXsGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712041581; c=relaxed/simple; bh=AEbx+RmnKiZ8/35GAhMs4OXVY4rljyqeofdS3TwFRkw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=QZXW9TN8v2j/mD3zA3kg9oVF2AIuaBng5CIHbKpHu7a17wrhPGOw4vmb9IsjoBH6NJden/Trnhvpifoz11TqTknsdpRHEqPi1uwoBWXKc/Qn7FRwFIu1OE5oVu2T6Up6be+quWYtXlTXyuv3efnDEPa7qpFRQ65P0zxmTREVt8Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-513e10a4083so5466149e87.1; Tue, 02 Apr 2024 00:06:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712041574; x=1712646374; darn=gcc.gnu.org; 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=G72Xf+wkyHUOH64x2wCW8ypZSqsvzde8mLGD4k5S1NM=; b=G10fJUptszDlcZNYn5/TW+hE94siumM4RTXO5kKUma+H12U+EzU7W8RhjxRnn+VmHu p5qPcshotV1pIUgBWaKwSUhqs6pmC7tqwRlzctWG6ZHHmNDFctSJ1XbgMYsQ0bmRUJwl lzz2va8VioWwMvs8vkHm9YDW4X1TDSfPfW5t/RTiHz3pQ2MV2yifktFcBhCgpCmIZ5Oe GPFhEqWgvo57G+c+FAtCY/1fBauMuwAglw62BHa9Q9pnaeJZquRn+Lv15vqhBh/5ZU7I hEsnKMlpUBKWaDmrVvKlIeY/X00g/fbI+j40i+z8s2RP3DgtnFbXPSB2QbaQkI/VUZ1F Gpew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712041574; x=1712646374; 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=G72Xf+wkyHUOH64x2wCW8ypZSqsvzde8mLGD4k5S1NM=; b=aMbvk0v5v4q7fohb3mWzbaVl7VKKYnaAcXK9V4AQqK/hjim0MY9LPcswt6YSNVxEVc IhORrnFBjzb4Uro/YaPK8ler1PUrz/02btRb8nlkMUZpnBVgrJgwtU0Bj5Xdr0Mn+B+v ZucBZgmx6H3TXBCAPz+QOnXdRKYvNxFLlePZDo5CUNO6UigvQER8dlEY/22opNcTvTfw eF87mW7gWc6uSVJm5lt+VZKK5ssSzxQ2N+Z3aDXGaj4NJG3bBNYqVlrtoDRqkuhlDmPD TxyNlCZXZgEHPX9YoelkOewABCelE7kgVgt5R+GD/6aKfBD8a5LYaAyKTPwe8jmj6vg/ 4+5Q== X-Forwarded-Encrypted: i=1; AJvYcCXwgb+oO5gbiCg6j2DzCHsL5dgWi4qJcZOFR0OJ1mDgsUbzbp3UfbGKjriqpIfzpCaoCzncsSeOM2tpSTmgqGzJFb7n X-Gm-Message-State: AOJu0YzHAWBS+iRtaS9PO7h4Jr5BEb2moko6ySfhtXBvpdW+GX5g9KPE INj+wTe70pBZo4KEJ+MnIEzzYbBgkvG5op3nyWyZ5rQeyk33uVJBzNIygO/N+sSRS7C1o0UurP7 4yQ4v0fouSWfRJdneoTCynvCfepJ4We5E X-Google-Smtp-Source: AGHT+IGb/l7scEbKGPfznetJtuDdEnr/Rb8L7Y5L7MVRd2j5t66IzZznA9YJ5mzDErny8JtfMzQOB36pntFMThjGr2M= X-Received: by 2002:a2e:a606:0:b0:2d4:973e:247f with SMTP id v6-20020a2ea606000000b002d4973e247fmr7367651ljp.23.1712041573923; Tue, 02 Apr 2024 00:06:13 -0700 (PDT) MIME-Version: 1.0 References: <20240401133518.714608-1-qing.zhao@oracle.com> In-Reply-To: <20240401133518.714608-1-qing.zhao@oracle.com> From: Richard Biener Date: Tue, 2 Apr 2024 09:06:03 +0200 Message-ID: Subject: Re: [PATCH][Backport][GCC10] Fix SSA corruption due to widening_mul opt on conflict across an abnormal edge [PR111407] To: Qing Zhao Cc: gcc-patches@gcc.gnu.org, pinskia@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 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 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 Mon, Apr 1, 2024 at 3:36=E2=80=AFPM Qing Zhao wro= te: > > This is a bug in tree-ssa-math-opts.c, when applying the widening mul > optimization, the compiler needs to check whether the operand is in a > ABNORMAL PHI, if YES, we should avoid the transformation. > > PR tree-optimization/111407 > > gcc/ChangeLog: > > * tree-ssa-math-opts.c (convert_mult_to_widen): Avoid the transfo= rm > when one of the operands is subject to abnormal coalescing. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr111407.c: New test. > > (cherry picked from commit 4aca1cfd6235090e48a53dab734437740671bbf3) > > bootstraped and regression tested on both aarch64 and x86. > > Okay for commit to GCC10? Note the GCC 10 branch is closed. If the patch boostraps/tests on the 11, 12 and 13 branches it is OK there. You do not need approval to backport fixes for _regressions_ if the patch cherry-picks without major edits and boostraps/tests OK. Thanks, Richard. > thanks. > > Qing > --- > gcc/testsuite/gcc.dg/pr111407.c | 21 +++++++++++++++++++++ > gcc/tree-ssa-math-opts.c | 8 ++++++++ > 2 files changed, 29 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/pr111407.c > > diff --git a/gcc/testsuite/gcc.dg/pr111407.c b/gcc/testsuite/gcc.dg/pr111= 407.c > new file mode 100644 > index 000000000000..a171074753f9 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr111407.c > @@ -0,0 +1,21 @@ > +/* PR tree-optimization/111407*/ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > +enum { SEND_TOFILE } __sigsetjmp(); > +void fclose(); > +void foldergets(); > +void sendpart_stats(int *p1, int a1, int b1) { > + int *a =3D p1; > + fclose(); > + p1 =3D 0; > + long t =3D b1; > + if (__sigsetjmp()) { > + { > + long t1 =3D a1; > + a1+=3D1; > + fclose(a1*(long)t1); > + } > + } > + if (p1) > + fclose(); > +} > diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c > index dd0b8c6f0577..47981da20e05 100644 > --- a/gcc/tree-ssa-math-opts.c > +++ b/gcc/tree-ssa-math-opts.c > @@ -2543,6 +2543,14 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_i= terator *gsi) > if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2)) > return false; > > + /* if any one of rhs1 and rhs2 is subject to abnormal coalescing, > + avoid the tranform. */ > + if ((TREE_CODE (rhs1) =3D=3D SSA_NAME > + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)) > + || (TREE_CODE (rhs2) =3D=3D SSA_NAME > + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs2))) > + return false; > + > to_mode =3D SCALAR_INT_TYPE_MODE (type); > from_mode =3D SCALAR_INT_TYPE_MODE (type1); > if (to_mode =3D=3D from_mode) > -- > 2.31.1 >