]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
optabs: Fix widening optabs for vec-mode -> scalar-mode [PR116926]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 4 Feb 2025 03:58:45 +0000 (19:58 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 4 Feb 2025 08:19:09 +0000 (00:19 -0800)
r15-4317-ga6f4404689f12 tried to add support for widending optabs
for vec-mode -> scalar-mode but it misunderstood how FOR_EACH_MODE worked,
the limit in this case is not inclusive. Which means setting limit to from,
would cause the loop not be executed at all. This fixes by setting the
limit to be the next mode after from mode.

Note the original version that added the widening optabs for vec-mode -> scalar-mode
(https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665021.html) didn't have this
bug, only the second version with suggested change
(https://gcc.gnu.org/pipermail/gcc-patches/2024-October/665068.html) dud. The suggested
change missed this issue with FOR_EACH_MODE.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/116926

gcc/ChangeLog:

* optabs-query.cc (find_widening_optab_handler_and_mode): Fix
limit for `vec-mode -> scalar-mode` case.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/optabs-query.cc

index 65eeb5d8e519e8bebbc2e17d56764d034223ed46..f5ca98da818a7ae2f85c9fedd668afc97184e2e9 100644 (file)
@@ -492,7 +492,7 @@ find_widening_optab_handler_and_mode (optab op, machine_mode to_mode,
     {
       gcc_checking_assert (VECTOR_MODE_P (from_mode)
                           && GET_MODE_INNER (from_mode) < to_mode);
-      limit_mode = from_mode;
+      limit_mode = GET_MODE_NEXT_MODE (from_mode).require ();
     }
   else
     gcc_checking_assert (GET_MODE_CLASS (from_mode) == GET_MODE_CLASS (to_mode)