]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
vect: Add assert to expand_vector_conversion [PR118616]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sun, 23 Mar 2025 17:38:39 +0000 (10:38 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 24 Mar 2025 23:10:29 +0000 (16:10 -0700)
In some cases (after inliing due to LTO and -O3), GCC cannot
figure out that the length of the converts vect is not empty
when supportable_indirect_convert_operation returns true. So
we get an extra warning because we loop through all but the last
entry and GCC decided that `converts.length () - 1` is -1. This
adds an assert to avoid the warning and maybe even produce slightly
better code for this function. A gcc_checking_assert would be better
here but we don't convert that into an assume attribute or
`if(!a) __builtin_unreachable();`, I filed PR 119439  for that.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/118616
gcc/ChangeLog:

* tree-vect-generic.cc (expand_vector_conversion): Add
an assert that converts vect is non empty if
supportable_indirect_convert_operation returns true.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/tree-vect-generic.cc

index 173ebd9a7ba6cfd1e7c7b4829f8b3e44c7d1e4a2..80c2d31776bb3c05001197733093aedc3f77cfa7 100644 (file)
@@ -1759,6 +1759,7 @@ expand_vector_conversion (gimple_stmt_iterator *gsi)
                                              converts))
     {
       new_rhs = arg;
+      gcc_assert (!converts.is_empty ());
       for (unsigned int i = 0; i < converts.length () - 1; i++)
        {
          new_lhs = make_ssa_name (converts[i].first);