From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C846B385800B; Fri, 16 Feb 2024 15:52:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C846B385800B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708098726; bh=96WMSGyoIin4WWLjZorccIle3jbtJ8BxonDm+uNGAdk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mlN3xv7ulk8n+pzhkdh1jqjNgeRgCzOzsWcBaQdIKWS8pQHy8kuYVLcXOHvwtTtGU RoqdAK83BCLn5NpC1qiVPxWKdqGlX2tOxa7FW/URcruLqp2f+8OFAf5pwr9MCNfRHA 5AprQZ8mOe0yXgM88S24AOcNiSZyJROOfUbid6e4= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/113907] [12/13/14 regression] ICU miscompiled since on x86 since r14-5109-ga291237b628f41 Date: Fri, 16 Feb 2024 15:52:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka 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: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113907 Jan Hubicka changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|[14 regression] ICU |[12/13/14 regression] ICU |miscompiled since on x86 |miscompiled since on x86 |since |since |r14-5109-ga291237b628f41 |r14-5109-ga291237b628f41 --- Comment #41 from Jan Hubicka --- OK, the reason why this does not work is that ranger ignores earlier value ranges on everything but default defs and phis. // This is where the ranger picks up global info to seed initial // requests. It is a slightly restricted version of // get_range_global() above. // // The reason for the difference is that we can always pick the // default definition of an SSA with no adverse effects, but for other // SSAs, if we pick things up to early, we may prematurely eliminate // builtin_unreachables. // // Without this restriction, the test in g++.dg/tree-ssa/pr61034.C has // all of its unreachable calls removed too early. // // See discussion here: // https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html void gimple_range_global (vrange &r, tree name, struct function *fun) { tree type =3D TREE_TYPE (name); gcc_checking_assert (TREE_CODE (name) =3D=3D SSA_NAME); if (SSA_NAME_IS_DEFAULT_DEF (name) || (fun && fun->after_inlining) || is_a (SSA_NAME_DEF_STMT (name))) {=20 get_range_global (r, name, fun); return; } r.set_varying (type); } This makes ipa-prop to ignore earlier known value range and mask the bug.=20 However adding PHI makes the problem to reproduce: #include #include int data[100]; int c; static __attribute__((noinline)) int bar (int d, unsigned int d2) { if (d2 > 30) c++; return d + d2; } static int test2 (unsigned int i) { if (i > 100) __builtin_unreachable (); if (__builtin_expect (data[i] !=3D 0, 1)) return data[i]; for (int j =3D 0; j < 100; j++) data[i] +=3D bar (data[j], i&1 ? i+17 : i + 16); return data[i]; } static int test (unsigned int i) { if (i > 10) __builtin_unreachable (); if (__builtin_expect (data[i] !=3D 0, 1)) return data[i]; for (int j =3D 0; j < 100; j++) data[i] +=3D bar (data[j], i&1 ? i+17 : i + 16); return data[i]; } int main () { int ret =3D test (1) + test (2) + test (3) + test2 (4) + test2 (30); if (!c) abort (); return ret; } This fails with trunk, gcc12 and gcc13 and also with Jakub's patch.=