From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id DC53C3858404 for ; Sun, 10 Mar 2024 21:05:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC53C3858404 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 DC53C3858404 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710104728; cv=none; b=td3fONvl8izEJ+xV/oLxyac5PxO5k0ElMVCYQeXSiJWJHDUA4wkqFGnH7OusPia8ZTQCwgWHl4OcpwEd6thIqpns8BsDkM4zpJ7P6Qc5+qrixqZw2nNTK8+VW/jgqeVn2LbtzMMEw3QpjUvJjF4pNqE5riDBI2dVjZgencDuujY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710104728; c=relaxed/simple; bh=BWbzABjcS6dvUmr+UWSt7hBANIm2B8l3loryKysymMc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=IgsMSRTbDl5J9a7Qh5Ny/NB8N7qYRfQZQX9ujSwcQH2iJOeeGehYltDubrDYEyFeXNAeMM2Uor3cWsJWFNCt15XBdbF/BNTTyUemVbTEpkOA+DOgbFp9/jO6i/9VNsbyqhj6vc/y7hvQXgYq81GvNGAHGY3bumkXXz7CBssQ0rk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dd68d4cff1so16261575ad.2 for ; Sun, 10 Mar 2024 14:05:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710104726; x=1710709526; 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=jn7OAMoORpXpQ+48EZBqHGlXpZMKxmSnA3qLSghJgbg=; b=A7murC7YDQtgHXmNJaAdorxUUj9o9DmHd7g8cNzYtY1PENKD73tCDUTUL3PzgBqI2U BT2NKhZcmwNqgClwy8Zngdb6Y3DuzpsCWK06lDJWCd+WTBJSwFtv/T3ZEagpkh2lRIEx gTI+Ogti3AssFFPh6J0UVuFkaIurngC3XH/nwyjiIrXKpF8WROmWJVdH/3ncYOjGghTt defao73OSv92+2O1fQnONBWlUeCdexUv8eWS/KUNWYPppcztMu+bfZ6UDJ/nr/m7n4hw eIx+v8+PecpVgmXWm4VjhUEJc36jl6Dg7cN9fZQWLqZ7oonXc/2U9S9Q9aV7+aXBK/S/ 9IwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710104726; x=1710709526; 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=jn7OAMoORpXpQ+48EZBqHGlXpZMKxmSnA3qLSghJgbg=; b=XhyOPrsKCJVQjodm8Hqm8Lh0bDKmdMYFWgtN6FNcAiiQJ7ApQqrFt3zWFIHoo2sXdp j3y3Q14FE8R6YWWqVrVBeJPZZl1VmMdNLNjRmN7j2mTiJnt+MBci8mh5WHasiATk9FNm 8nhK9pE/fT62kV7EyhGJVCzNVU33Y32BWgJDnzhUlrke3ez3xd3cItbUZ+6UXWPiK86M ehrtYxavZqfQ+cMRQhlR5t4y4ZlBaEUpMzV095rkkub1NTO7Dn/LfWSHeCpM5MJgjkNl PPSfqEzEM6MNSDfW5mi0LwE52Ufzx6EqoceDGCNHefX2tYYdqp8nQnaLysLTdtgjyAQu eBhQ== X-Gm-Message-State: AOJu0YyR22P0l5gtNYX/0lCn+kuhhj2LTyQZy+0zfYKMsRnTn9RtXlOj bfy+K5Zri6ixc0pFE9GWkvdNdwTf6cdV1RWSrA8g5jaZDhlGsF0kdSQMroQkG5p6v8PDzJUbMWs MwYTSS/gmKaXQuhHaiW2hORAUKmnUr9Ea3zo= X-Google-Smtp-Source: AGHT+IH5811XoRc5tD6Q5UZVRYjMVV04lBt0gDKl4RjRCUMXbs9DVzTIcD1/6hNarHTxYDsFkQKJzo5VAzhWPavE//E= X-Received: by 2002:a17:903:11cf:b0:1dc:ca72:8318 with SMTP id q15-20020a17090311cf00b001dcca728318mr4604794plh.37.1710104725704; Sun, 10 Mar 2024 14:05:25 -0700 (PDT) MIME-Version: 1.0 References: <4fb49d29-3688-4c14-991f-196ca086d479@ventanamicro.com> In-Reply-To: <4fb49d29-3688-4c14-991f-196ca086d479@ventanamicro.com> From: Andrew Pinski Date: Sun, 10 Mar 2024 14:05:13 -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.0 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:04=E2=80=AFPM Jeff Law wr= ote: > > Here's a potential approach to fixing PR92539, a P2 -Warray-bounds false > 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 because > 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 did > this kind of test. > > Comments/Suggestions? ENOPATCH > > Jeff