From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 82F4A3858D1E for ; Wed, 17 May 2023 06:29:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82F4A3858D1E 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-x132.google.com with SMTP id 2adb3069b0e04-4f13a72ff53so535306e87.0 for ; Tue, 16 May 2023 23:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684304961; x=1686896961; 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=v/WDQKGZJePdzypJTOTl7Wzwy8HEbesqCaaa62Vgy8w=; b=X6Os+wfM0VMeal3cbkSdR5R5MOYCJ9NNVXZQl87jWe1dm7EUdSc1GQPMKDGyM1+iCj pUGtmupkBcQeKAyPgvMHF9wr4B6AT+gHKtQQgpWTU68PWqQ4oV71UGCqYpCm1Sm0aXBR qMnAwZV3VmNT/CPU2/zcbHjDIciNUAe2pH6LnBlV10UCT017e1WQkrBN5mGXYlDQopXC q9vTWWIbi4JUdVgvxCtD3PC1mxlKABBPhGdhPcD7GpET+EMOubt4aK5atmz4x3Yt0to9 QzdwnmIHp9GHqcVIih4o1oCONcL1nj8Cfc1Sz7+8sWgskjh3p1L3bgS4Hs8sWPtrio67 sZkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684304961; x=1686896961; 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=v/WDQKGZJePdzypJTOTl7Wzwy8HEbesqCaaa62Vgy8w=; b=V3W1iYtvey3hmDt4n3aEr0TTP3tPfwJ4wYbHYrGYuKMOhK6S7mgzy+arEuZwQkzW0+ bfsro3+gpcn0fPr1F2P49pln/dx+uSeInCwI1XGH6MpVVW9AddWrE/W/2dZ2pmeaKqbw 9+EyCsXcK/8ZfeeMgL6foM0cepE77hbSEoVOHa+456SM+5/jIpWc24Tv/VhXjo73/4tt wbIiRPkfR35QndON+ChT2XKEmkmWsKEWhJ0OtfoeG2T3t/EmVF2k3iNZj+kdX67ZRZ+v dLB5ZY4/FWavyht/PCVpA4w4881/YH2oGiJ4Ul3NoQ47EiLgWqloJVzQQXPk1YkJV0oJ SyuQ== X-Gm-Message-State: AC+VfDy9bMS94GttWKdfVu3dRsOemtxDSgLXVpy8cCACnjFuzRKT2qyI d/nKK+3ln7zvKy/kAR68l7kxmD2m5YHfxe7+sjM= X-Google-Smtp-Source: ACHHUZ7sv1BuO5+0EBWTw4njtJgyDlJDhpaWm8oIaZnoRxRPDgvxU8E+xlFzWEFxncc1UPDUxLsKa+ylGpYqYxPXZGQ= X-Received: by 2002:a05:6512:38d1:b0:4f1:1eb3:2f27 with SMTP id p17-20020a05651238d100b004f11eb32f27mr7901181lft.54.1684304960655; Tue, 16 May 2023 23:29:20 -0700 (PDT) MIME-Version: 1.0 References: <20230517005256.1718424-1-apinski@marvell.com> In-Reply-To: <20230517005256.1718424-1-apinski@marvell.com> From: Richard Biener Date: Wed, 17 May 2023 08:29:07 +0200 Message-ID: Subject: Re: [PATCH] Fix PR 106900: array-bounds warning inside simplify_builtin_call To: Andrew Pinski Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.6 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 Wed, May 17, 2023 at 2:54=E2=80=AFAM Andrew Pinski via Gcc-patches wrote: > > The problem here is that VRP cannot figure out isize could not be 0 > due to using integer_zerop. This patch removes the use of integer_zerop > and instead checks for 0 directly after converting the tree to > an unsigned HOST_WIDE_INT. This allows VRP to figure out isize is not 0 > and `isize - 1` will always be >=3D 0. > > This patch is just to avoid the warning that GCC could produce sometimes > and does not change any code generation or even VRP. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. OK. Richard. > gcc/ChangeLog: > > * tree-ssa-forwprop.cc (simplify_builtin_call): Check > against 0 instead of calling integer_zerop. > --- > gcc/tree-ssa-forwprop.cc | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc > index 06f19868ade..0326e6733e8 100644 > --- a/gcc/tree-ssa-forwprop.cc > +++ b/gcc/tree-ssa-forwprop.cc > @@ -1231,14 +1231,14 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_= p, tree callee2) > tree size =3D gimple_call_arg (stmt2, 2); > /* Size must be a constant which is <=3D UNITS_PER_WORD and > <=3D the string length. */ > - if (TREE_CODE (size) !=3D INTEGER_CST || integer_zerop (size)) > + if (TREE_CODE (size) !=3D INTEGER_CST) > break; > > if (!tree_fits_uhwi_p (size)) > break; > > unsigned HOST_WIDE_INT sz =3D tree_to_uhwi (size); > - if (sz > UNITS_PER_WORD || sz >=3D slen) > + if (sz =3D=3D 0 || sz > UNITS_PER_WORD || sz >=3D slen) > break; > > tree ch =3D gimple_call_arg (stmt2, 1); > -- > 2.31.1 >