From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 78EF93858C2C; Wed, 2 Feb 2022 12:30:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78EF93858C2C From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104334] [12 Regression] Ranger/dom miscompilation Date: Wed, 02 Feb 2022 12:30:40 +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: 12.0 X-Bugzilla-Keywords: lto, needs-bisection, wrong-code X-Bugzilla-Severity: blocker X-Bugzilla-Who: rguenther at suse dot de 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: 12.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: Wed, 02 Feb 2022 12:30:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104334 --- Comment #10 from rguenther at suse dot de --- On Wed, 2 Feb 2022, rsandifo at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104334 >=20 > --- Comment #9 from rsandifo at gcc dot gnu.org --- > (In reply to Jakub Jelinek from comment #7) > > The difference might be in: > > 1938 /* Optimize comparisons with constants. */ > > 1939 if (STATIC_CONSTANT_P (yi.len =3D=3D 1 && yi.val[0] >=3D 0)) > > 1940 return xi.len =3D=3D 1 && xi.to_uhwi () < (unsigned HOST_WIDE_= INT) > > yi.val[0]; > > 1941 if (STATIC_CONSTANT_P (xi.len =3D=3D 1 && xi.val[0] >=3D 0)) > > 1942 return yi.len !=3D 1 || yi.to_uhwi () > (unsigned HOST_WIDE_IN= T) > > xi.val[0]; > > 1943 /* Optimize the case of two HWIs. The HWIs are implicitly > > sign-extended > > 1944 for precisions greater than HOST_BITS_WIDE_INT, but sign-exte= nding > > both > > 1945 values does not change the result. */ > > 1946 if (__builtin_expect (xi.len + yi.len =3D=3D 2, true)) > > 1947 { > > 1948 unsigned HOST_WIDE_INT xl =3D xi.to_uhwi (); > > 1949 unsigned HOST_WIDE_INT yl =3D yi.to_uhwi (); > > 1950 return xl < yl; > > 1951 } > > Perhaps with LTO STATIC_CONSTANT_P (yi.len && iy.val[0] >=3D 0) is true= while > > without LTO it is false. > > I'll verify that. Though, xi.len =3D=3D 1, xi.to_uhwi () is 3, yi.val[= 0] is 4 > > and yi.to_uhwi () is 0. > > So I think if STATIC_CONSTANT_P is true, it will return 3 < 4, while if= it > > is false, it will return 3 < 0. > >=20 > > Now, the question is, do we consider those wi::lt_p (x, 4, sign) calls > > invalid if 4 is not representable in type, > > or does the STATIC_CONSTANT_P case need to also check precision, or mask > > Xi.val[0]? > At the moment I think they're invalid. If we want to change that, > and have the value be implicitly truncated, we should probably do > it by setting primitive_int_traits::is_sign_extended to false. I also think they are invalid. I guess primitive_int_traits always produce "widest_ints", but I don't know whether we can reasonably reject the wi:lt_p (x, 4, sign) calls in favor of requiring wi::lt_p (wi::to_widest (x), 4, sign) at compile-time ... I don't think we want to silenlty truncate the literal '4', instead if we really want, we could ICE with checking enabled ...=