From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B1F183858C35; Wed, 20 Mar 2024 12:36:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1F183858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710938175; bh=NrgtsLlltFSy5DOLSmqPBWXP/+HMMlqGpGrdbKfvdaQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pcstshAU7rJtG53JIl/r/5oxgUZ2TwD96mmHdDNH97BR0D2nOVuUOZm3aWxi1bLdT ca2bUrczaHVdvPVhnDIGeZaywYcqyglQNlfvuICfyBLg+4jSxMV87dwmESuPt9oQZw IyGbyWubB8hPaRABRQerV1wM+tYPKRlbvmK08pH4= From: "liuhongt at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114396] [13/14 Regression] Vector: Runtime mismatch at -O2 with -fwrapv since r13-7988-g82919cf4cb2321 Date: Wed, 20 Mar 2024 12:36:15 +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: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: liuhongt 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: 13.3 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=3D114396 --- Comment #15 from Hongtao Liu --- (In reply to Richard Biener from comment #9) > (In reply to Robin Dapp from comment #8) > > No fallout on x86 or aarch64. > >=20 > > Of course using false instead of TYPE_SIGN (utype) is also possible and > > maybe clearer? >=20 > Well, wi::from_mpz doesn't take a sign argument. It's comment says >=20 > /* Returns X converted to TYPE. If WRAP is true, then out-of-range > values of VAL will be wrapped; otherwise, they will be set to the > appropriate minimum or maximum TYPE bound. */ > wide_int > wi::from_mpz (const_tree type, mpz_t x, bool wrap) >=20 > I'm not sure if we really want saturating behavior here, so 'true' is > more correct? Note if we want an unsigned result we should pass utype he= re, > that might be the bug? So >=20 > begin =3D wi::from_mpz (utype, res, true); >=20 > ? Yes, it should be. >=20 > The to_mpz args look like they could be mixing signs as well: >=20 > case vect_step_op_mul: > { > tree utype =3D unsigned_type_for (type); > init_expr =3D gimple_convert (stmts, utype, init_expr); > wide_int skipn =3D wi::to_wide (skip_niters); > wide_int begin =3D wi::to_wide (step_expr); > auto_mpz base, exp, mod, res; > wi::to_mpz (begin, base, TYPE_SIGN (type)); >=20 > TYPE_SIGN (step_expr)? step_expr should have same type as init_expr. >=20 > wi::to_mpz (skipn, exp, UNSIGNED); >=20 > TYPE_SIGN (skip_niters) (which should be UNSIGNED I guess)? skipn must be a postive value, so I assume UNSIGNED/SIGNED doesn't make any difference here.=