From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 79D083857019; Thu, 8 Jun 2023 21:00:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79D083857019 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686258054; bh=dxtPPl5xG9ZzETOivvhQZ58/eXgiF/NKtb/NjKQBjD4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Nn3eslU00LcfR4FNq8JgLEgfEDJALxLiCkUI5A5vTJLXCfnxIZcRSdyz4HRdvQGH1 BqvoxpBnRCKWMT73RmfXMk6FJDeXDKm4H8GIi3So0jC3hnjwgh/Jwm5cS8T/TfBkC/ 0y45q/rnY9esXWv8Oh8w3tf+iv1yGS8pcASJU/vc= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/110182] Vector(2) cast from double to float and subtraction seems to produce incorrect results at -O2 and above Date: Thu, 08 Jun 2023 21:00:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: component 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=3D110182 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |target Summary|GCC generates incorrect |Vector(2) cast from double |results for simple Eigen |to float and subtraction |Casts / Subtractions at -O2 |seems to produce incorrect |or above for a 3 |results at -O2 and above |dimensional vector | --- Comment #1 from Andrew Pinski --- Looks like a target issue: The gimple level looks like this in GCC 12 for low: vect__178.810_465 =3D (vector(2) float) _165; vect__202.814_467 =3D _165 - _165; vect__203.815_466 =3D (vector(2) float) vect__202.814_467; _172 =3D SR.808_30 * 6.371e+6; MEM[(struct plain_array *)&high] =3D{v} {CLOBBER}; MEM [(float &)&high] =3D vect__178.810_465; _184 =3D (float) _172; MEM[(float &)&high + 8] =3D _184; MEM[(struct plain_array *)&low] =3D{v} {CLOBBER}; MEM [(float &)&low] =3D vect__203.815_466; While for GCC 11 we have the casting as scalar: _173 =3D (float) _298; MEM[(float &)&high] =3D _173; _296 =3D BIT_FIELD_REF <_160, 64, 64>; _177 =3D (float) _296; MEM[(float &)&high + 4] =3D _177; _179 =3D (float) _167; MEM[(float &)&high + 8] =3D _179; MEM[(struct plain_array *)&low] =3D{v} {CLOBBER}; _192 =3D (double) _173; _197 =3D _298 - _192; _198 =3D (float) _197; MEM[(float &)&low] =3D _198; _224 =3D (double) _177; _229 =3D _296 - _224; _230 =3D (float) _229; MEM[(float &)&low + 4] =3D _230; _208 =3D (double) _179; _213 =3D _167 - _208; _214 =3D (float) _213; MEM[(float &)&low + 8] =3D _214;=