From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E12D23857C4A; Thu, 7 Mar 2024 07:32:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E12D23857C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709796720; bh=94aj77VwLQXQo9CqTdDedC2Aog6w08qb6vIdZI6TYGs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JSXUWyN7+qsTwYtb6YHl9v9HuESsko0p2l9HUbzQgzkFvA8rKnbQmtTi0q+yTlNCc KiGSEM3I1k93MLUA8Xkv3T5VPkd4tWfg7hRBCcVu8YP30B/J5kfLSp90EIZFotquzQ o1ecmFoFIZayjOCDJxjshV6MfXiiSnnM1dtb01Ko= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105533] UBSAN: gcc/expmed.cc:3272:26: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long int' Date: Thu, 07 Mar 2024 07:32:00 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105533 --- Comment #10 from rguenther at suse dot de --- On Wed, 6 Mar 2024, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105533 >=20 > Jakub Jelinek changed: >=20 > What |Removed |Added > -------------------------------------------------------------------------= --- > CC| |rguenth at gcc dot gnu.o= rg >=20 > --- Comment #7 from Jakub Jelinek --- > The second UB is on > #2 ao_ref_init_from_vn_reference (ref=3D, set=3D1, base_s= et=3D1, > type=3D, ops=3D...) at ../../gcc/tree-ssa-sccvn.cc:1224 > 1224 offset +=3D op->off << LOG2_BITS_PER_UNIT; > where op->off is negative. > Isn't this just an unnecessary optimization? I mean can't we just do > offset +=3D op->off * BITS_PER_UNIT; > BITS_PER_UNIT is a constant 8 on all targets we support... It's a habit from dealing with offset_int (but this is poly_int64) where the multiply is possibly a lot more costly than a shift. So yeah, a multiply is fine I guess.=