From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB03B38930E9; Fri, 24 Apr 2020 08:34:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB03B38930E9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587717241; bh=c2XzAbFlgNBS7LUXbOgxC/rgkE66XytdElCiYHOGB/o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fpblvNO/NaoN9IFD2sNTuvv05YgeE6xqAMKkrdxvSO3GMszxTrKTrS5crxkrquE7U GE8Hr17n6rkZRkisEabkv/L3lXL+b9t6ZaUM7YXSfM14rxERV1jocgTzptCUJVdLJ2 Bz7OH6szgQNMGK6gko4W4Q6RbBQHUjF9ZwMYPQ/I= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94734] [10 Regression] Program crashes when compiled with -O2 since r10-1892-gb9ef6a2e04bfd013 Date: Fri, 24 Apr 2020 08:34:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Apr 2020 08:34:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94734 --- Comment #10 from Jakub Jelinek --- Yeah. add_or_mark_expr could be extended to handle more complex addresses (perhaps get_inner_reference and hash on the decl + offset expression and taking into account the bitpos/bitsize then? Further testcase. Both foo and bar are miscompiled, baz is fine because ar= r[7] is known to be always within the object bounds. __attribute__((noipa)) int foo (int n) { int arr[16], s =3D 0; for (int i =3D 0; i < n; i++) { if (i < 16) arr[i] =3D i; } for (int i =3D 0; i < 16; i++) s +=3D arr[i]; return s; } __attribute__((noipa)) int bar (int n, int x, unsigned long y, unsigned long z) { int arr[16], s =3D 0; arr[4] =3D 42; for (int i =3D 0; i < n; i++) { if (x =3D=3D (i & 0x25)) arr[y] =3D i; } return arr[z]; } __attribute__((noipa)) int baz (int n, int x, unsigned long z) { int arr[16], s =3D 0; arr[12] =3D 42; for (int i =3D 0; i < n; i++) { if (x =3D=3D (i & 0x25)) arr[7] =3D i; } return arr[z]; } int main () { if (foo (10374) !=3D 15 * 16 / 2) __builtin_abort (); if (bar (25, 0x25, (unsigned long) 0xdeadbeefbeefdeadULL, 4) !=3D 42) __builtin_abort (); if (bar (25, 4, 17, 17) !=3D 22) __builtin_abort (); if (baz (25, 0x25, 12) !=3D 42) __builtin_abort (); if (baz (25, 4, 7) !=3D 22) __builtin_abort (); if (baz (25, 4, 12) !=3D 42) __builtin_abort (); return 0; }=