]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix PR 110554: vec lowering introduces scalar signed-boolean:32 comparisons
authorAndrew Pinski <apinski@marvell.com>
Wed, 5 Jul 2023 03:38:06 +0000 (20:38 -0700)
committerAndrew Pinski <apinski@marvell.com>
Thu, 6 Jul 2023 06:19:51 +0000 (23:19 -0700)
So the problem is vector generic decided to do comparisons in signed-boolean:32
types but the rest of the middle-end was not ready for that. Since we are building
the comparison which will feed into a cond_expr here, using boolean_type_node is
better and also correct. The rest of the compiler thinks the ranges for
comparison is always [0,1] too.

Note this code does not currently lowers bigger vector sizes into smaller
vector sizes so using boolean_type_node here is better.

OK? bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

PR middle-end/110554
* tree-vect-generic.cc (expand_vector_condition): For comparisons,
just build using boolean_type_node instead of the cond_type.
For non-comparisons/non-scalar-bitmask, build a ` != 0` gimple
that will feed into the COND_EXPR.

gcc/tree-vect-generic.cc

index df04a0db68da3222f43dd938f8e7adb186cd93c9..a7e6cb87a5e31e3dd2a893ea5652eeebf8d5d214 100644 (file)
@@ -1121,7 +1121,7 @@ expand_vector_condition (gimple_stmt_iterator *gsi, bitmap dce_ssa_names)
                                       comp_width, comp_index);
          tree aa2 = tree_vec_extract (gsi, comp_inner_type, a2,
                                       comp_width, comp_index);
-         aa = gimplify_build2 (gsi, code, cond_type, aa1, aa2);
+         aa = gimplify_build2 (gsi, code, boolean_type_node, aa1, aa2);
        }
       else if (a_is_scalar_bitmask)
        {
@@ -1132,7 +1132,11 @@ expand_vector_condition (gimple_stmt_iterator *gsi, bitmap dce_ssa_names)
                                build_zero_cst (TREE_TYPE (a)));
        }
       else
-       aa = tree_vec_extract (gsi, cond_type, a, comp_width, comp_index);
+       {
+         result = tree_vec_extract (gsi, cond_type, a, comp_width, comp_index);
+         aa = gimplify_build2 (gsi, NE_EXPR, boolean_type_node, result,
+                               build_zero_cst (cond_type));
+       }
       result = gimplify_build3 (gsi, COND_EXPR, inner_type, aa, bb, cc);
       if (!CONSTANT_CLASS_P (result))
        constant_p = false;