From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 67CE8385780C; Wed, 13 Apr 2022 13:48:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67CE8385780C From: "tnfchris at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105219] [12 Regression] SVE: Wrong code with -O3 -msve-vector-bits=128 -mtune=thunderx Date: Wed, 13 Apr 2022 13:48:57 +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.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tnfchris at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: tnfchris 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, 13 Apr 2022 13:48:57 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105219 --- Comment #10 from Tamar Christina --- nb_iterations_upper_bound is indeed set incorrectly and tracked to this com= mit, commit 7ed1cd9665d8ca0fa07b2483e604c25e704584af Author: Andre Vieira Date: Thu Jun 3 13:55:24 2021 +0100 vect: Use main loop's thresholds and VF to narrow upper_bound of epilog= ue This patch uses the knowledge of the conditions to enter an epilogue lo= op to help come up with a potentially more restricive upper bound. gcc/ChangeLog: * tree-vect-loop.c (vect_transform_loop): Use main loop's vario= us' thresholds to narrow the upper bound on epilogue iterations. gcc/testsuite/ChangeLog: * gcc.target/aarch64/sve/part_vect_single_iter_epilog.c: New te= st. I don't quite understand when comparing the two bounds there's a -1 in the = min comparison. And indeed: diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 5c7b163f01c..19235ea79fe 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -9971,7 +9971,7 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call) LOOP_VINFO_VECT_FACTOR (loop_vinfo), &bound)) loop->nb_iterations_upper_bound - =3D wi::umin ((widest_int) (bound - 1), + =3D wi::umin ((widest_int)bound, loop->nb_iterations_upper_bound); } } fixes it. It looks to me that when comparing the bounds of the main loop and epilogue you shouldn't subtract 1 again. But need to ask why this is there.=