From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 30CB43858C54; Fri, 10 Mar 2023 09:58:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30CB43858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678442333; bh=0lYLfthlgS684F4hageF4lqglXOB5JC3sY7ZvOg69Yg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=criRR8jKsIXdsoZIDhtJuIHueobgOY/kQU+h9UhtDukVesX9EPsI01MpAiyADalAn 4edzopHLlgFDqK0sh/OO2wNVLRBynRM6Eznbohx4Mq0C3XuTUVc3rj/1NMZ7pgBCUd 7F9GlviUWr/SheI0QGuyYbUq/+k0NXALfPp907MU= From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/109069] [12/13 Regression] Vector truncation test program produces incorrect result since r12-6537-g080a06fcb076b3 Date: Fri, 10 Mar 2023 09:58:51 +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: 12.1.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: linkw at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc cf_known_to_work 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=3D109069 Kewen Lin changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Vector truncation test |[12/13 Regression] Vector |program produces incorrect |truncation test program |result on big-endian |produces incorrect result |powerpc64-linux-gnu with |since |-mcpu=3Dpower10 -O2 |r12-6537-g080a06fcb076b3 Known to work| |11.3.0 --- Comment #7 from Kewen Lin --- One test case can be: #include __attribute__ ((noipa)) vector signed int test () { vector signed int v =3D {-16, -16, -16, -16}; vector signed int res =3D vec_sld (v, v, 3); return res; } int main () { vector signed int res =3D test (); if (res[0] !=3D 0xf0ffffff) __builtin_abort (); return 0; } It fails on Power7,8,9,10. It starts to fail from r12-6537-g080a06fcb076b3, when the two input operands are the same, it's only safe to optimize it int= o a vector move no matter what's the shift count is that the given vector is a const vec_duplicate and the duplicated element is affordable in a byte. The culprit commit is incorrect to use easy_vector_constant as predicate, which just guards those vector constants without memory loading. The reason why the reporter only saw this on Power10 is that the given cons= tant 0xFA578D00u can only satisfy "easy_vector_constant" till power10. The constructed test case above adopts one constant which can be built with vspltisw, then we can easily see the failure.=