From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by sourceware.org (Postfix) with ESMTPS id A013A3858281 for ; Mon, 11 Mar 2024 03:19:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A013A3858281 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 A013A3858281 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710127166; cv=none; b=T6Oc3xUHHRcheclZl/BEVdFREb90vUT4757fsD2pyjpgMM44RUU7Fq14dThz25zVF85heQP3LQJFCQmqHY1gjeEDwgJig67oGtn5abnUdlPuWrSwHOiS+qmsxuC6ucWGCI6059EyQ2gNox/Epg5RoOq+C9Fs2KFya1uyAnyYDXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710127166; c=relaxed/simple; bh=A3/0BmoIxifSWYhdFIyOFnq6W38O0qNeT06wwZGj6LA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ezXvKWWs0MMVDWRylQ2t44vhnY7QAA/YA0ydPrtefxxmQAAadIyLoD8EUKCwxYu3TVekMpZNCGs15Zs3eOoJqNmsTSABA/l2zOw7fvEIdvcpIpqKpj6SBvcTWwUMJ4E2ZTf5KrWRNHEOnsxXDJmYDQtuSsu4OZ00lBTVUiZwTdQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-29aa91e173dso2576130a91.0 for ; Sun, 10 Mar 2024 20:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710127162; x=1710731962; 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=fgtAI9CctGjClbhU1a6n0X9fzHtcZw6eVCgK5WdZoUA=; b=UezHC9iFGQqEcvR11TRf1pqHlyXoEhyOKAMPvVLWTdEeyOersw2aS19aibyRGwaLYN 7i4813OI7E2IbOm/tBjMcz9EX0JChY9UrLNxKUmEHNnwYB6VsJWUPa4Wqn7E5RjXwF6P D0ge95z9hzicwm2tcnGmASe7OuWoIaLgnumvdCG29a2slfAcpKheEMwJM6/C/+uVuU8m Ns1KXN36mS3I+fbYMBZ+cxyNvCxF/Ugq178UG7lDK4ZnJQyoFyivbQWv9TzIAY5WWNSa tyhW5XAbpNqYViNgzhJfm7LKd8nSOpV5Pp2ElGQG65gGWc9SDLyVJrjVPtH42dZUe9Qx zu8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710127162; x=1710731962; 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=fgtAI9CctGjClbhU1a6n0X9fzHtcZw6eVCgK5WdZoUA=; b=apptJ3GQo2M4yFgu8qPYeG6pcuADEgbs3BFWDRTlSaIcjOZPIfVLc8fBmC/gMfQnCt Y4Vg4xietykGbwJGVhwzs3AiqVj6zEDVgFjKVyH8RCXuF83Gc+V7T+eO+XBtBkoCUkND cL4Iz/ZBsim7RShE+Tk4IGl8vUv0D+ucjDpiUnzXDvoJnLtCiFRYl5Nu4p+/z1/37KY4 AJCiEgtjcKxYBQp6JsoCRxMPE2MJXLghEJP+5bdO04zAn8Ts2ELKK8dluc84IxTSQsV3 H3uzjDik/eFioQa/0c6XThqf4VEZZzmO3CGGpR0JUyy0XeUD/HubK6asF45TfhGv4nNO Vn3w== X-Gm-Message-State: AOJu0Yy/9KdUChGcW1tgLyMpeO/12Jk3I72T8NPyJhOn7SecGXvcfIbj 2mFVYKj9flSudxX3n7nrkyDdW+lR4fG/88AeLy4uHhupw6QWbIEfLVr8Ow72d5RuTvh2Mri4UdG jQJy7YlPGs6Z+4nlYQ37tTyvu8L8= X-Google-Smtp-Source: AGHT+IH1oqNB7A97ikaVAfYPo4JXT9FxNvzphFcwlKsGDBE9KOGDBkNckKodAxlBzDQWcyWXEuO9qiUs8m5dJAPYgbo= X-Received: by 2002:a17:90b:f10:b0:29b:8f6c:6b8c with SMTP id br16-20020a17090b0f1000b0029b8f6c6b8cmr3165211pjb.42.1710127162291; Sun, 10 Mar 2024 20:19:22 -0700 (PDT) MIME-Version: 1.0 References: <4fb49d29-3688-4c14-991f-196ca086d479@ventanamicro.com> <61bfe66a-6e08-4ca9-9f0a-81082762e702@ventanamicro.com> In-Reply-To: <61bfe66a-6e08-4ca9-9f0a-81082762e702@ventanamicro.com> From: Andrew Pinski Date: Sun, 10 Mar 2024 20:19:10 -0700 Message-ID: Subject: Re: [RFC] [PR tree-optimization/92539] Optimize away tests against invalid pointers To: Jeff Law Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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 Sun, Mar 10, 2024 at 2:09=E2=80=AFPM Jeff Law wr= ote: > > > > On 3/10/24 3:05 PM, Andrew Pinski wrote: > > On Sun, Mar 10, 2024 at 2:04=E2=80=AFPM Jeff Law wrote: > >> > >> Here's a potential approach to fixing PR92539, a P2 -Warray-bounds fal= se > >> positive triggered by loop unrolling. > >> > >> As I speculated a couple years ago, we could eliminate the comparisons > >> against bogus pointers. Consider: > >> > >>> [local count: 30530247]: > >>> if (last_12 !=3D &MEM [(void *)"aa" + 3B]) > >>> goto ; [54.59%] > >>> else > >>> goto ; [45.41%] > >> > >> > >> That's a valid comparison as ISO allows us to generate, but not > >> dereference, a pointer one element past the end of the object. > >> > >> But +4B is a bogus pointer. So given an EQ comparison against that > >> pointer we could always return false and for NE always return true. > >> > >> VRP and DOM seem to be the most natural choices for this kind of > >> optimization on the surface. However DOM is actually not viable becau= se > >> the out-of-bounds pointer warning pass is run at the end of VRP. So > >> we've got to take care of this prior to the end of VRP. > >> > >> > >> > >> I haven't done a bootstrap or regression test with this. But if it > >> looks reasonable I can certainly push on it further. I have confirmed = it > >> does eliminate the tests and shuts up the bogus warning. > >> > >> The downside is this would also shut up valid warnings if user code di= d > >> this kind of test. > >> > >> Comments/Suggestions? > > > > ENOPATCH > Yea, realized it as I pushed the send button. Then t-bird crashed, > repeatedly. > > Attached this time.. One minor comment on it The comment: > return true for EQ and false for NE. Seems to be the opposite for what the code does: > return code =3D=3D EQ_EXPR ? boolean_false_node : boolean_true_node; Thanks, Andrew > > jeff >