[PATCH] Vectorize COND_EXPR

Devang Patel dpatel@apple.com
Wed Apr 13 15:54:00 GMT 2005


On Apr 11, 2005, at 6:39 PM, Devang Patel wrote:

>
> On Apr 11, 2005, at 12:28 PM, Richard Henderson wrote:

[snip]

>> Lemme know when they're in and I'll add vcond patterns for
>> i386 and ia64.
>
> Done. I did another bootstrap and test run before applying. Note,  
> due to
> some recent changes (tcb?) if-converter is producing slightly  
> different
> stmts. This causes vect-ifcvt-? test failures.
>
> Instead of
>     r = x > y ? a : b;
> vectorizer gets
>     t1 = x > y;
>     r = t1 ? a : b;
>
> I'm testing a fix right now. I'll run it through SPEC before  
> posting patch
> tomorrow.

Here is the patch.

First check for is_gimple_condexpr() is not necessary because expr is
COND_EXPR_COND.

Second one is the reason behind this error. Second code snippet, to  
create
temp. variable, is responsible for t1 in above example. It is relevant
now after recent if-conversion fix to avoid condition from latch block.
Until, now I did not notice extra temp. because it does not cause any
trouble (other than not vectorizing loop). However now, example loop is
not vectorized so hard to ignore! This second code snippet is also
unnecessary because it creates an input for add_to_dst_predicate_list().
However, it is add_to_dst_predicate_list()'s responsibility to generate
temporary if required.

      * tree-if-conv.c (tree_if_convert_cond_expr): Do not create extra
      temp variables.

Bootstrapped and tested on powerpc-darwin. Test results:

Tests that now work, but didn't before:

gcc.dg/vect/vect-ifcvt-2.c scan-tree-dump-times vectorized 1 loops 1
gcc.dg/vect/vect-ifcvt-3.c scan-tree-dump-times vectorized 1 loops 1
gcc.dg/vect/vect-ifcvt-4.c scan-tree-dump-times vectorized 1 loops 1
gcc.dg/vect/vect-ifcvt-5.c scan-tree-dump-times vectorized 1 loops 1
gcc.dg/vect/vect-ifcvt-6.c scan-tree-dump-times vectorized 1 loops 1
gcc.dg/vect/vect-ifcvt-7.c scan-tree-dump-times vectorized 1 loops 1
gcc.dg/vect/vect-ifcvt-9.c scan-tree-dump-times vectorized 1 loops 2
gcc.dg/vect/vect-none.c scan-tree-dump-times vectorized 0 loops 2
gcc.dg/vect/vect-none.c scan-tree-dump-times vectorized 1 loops 1

I also bootstrapped with Auto Vectorizer ON. SPEC test run did not
complete successfully because of reasons not related to this patch.

OK for mainline ?
Thanks,
-
Devang

Index: tree-if-conv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-if-conv.c,v
retrieving revision 2.36
diff -Idpatel.pbxuser -c -3 -p -r2.36 tree-if-conv.c
*** tree-if-conv.c      9 Apr 2005 01:37:23 -0000       2.36
--- tree-if-conv.c      13 Apr 2005 15:39:58 -0000
*************** tree_if_convert_cond_expr (struct loop *
*** 277,291 ****

     c = COND_EXPR_COND (stmt);

-   /* Create temp. for condition.  */
-   if (!is_gimple_condexpr (c))
-     {
-       tree new_stmt;
-       new_stmt = ifc_temp_var (TREE_TYPE (c), unshare_expr (c));
-       bsi_insert_before (bsi, new_stmt, BSI_SAME_STMT);
-       c = TREE_OPERAND (new_stmt, 0);
-     }
-
     extract_true_false_edges_from_block (bb_for_stmt (stmt),
                                        &true_edge, &false_edge);

--- 277,282 ----
*************** tree_if_convert_cond_expr (struct loop *
*** 295,308 ****
     add_to_dst_predicate_list (loop, true_edge->dest, cond,
                              unshare_expr (c), bsi);

-   if (!is_gimple_reg(c) && is_gimple_condexpr (c))
-     {
-       tree new_stmt;
-       new_stmt = ifc_temp_var (TREE_TYPE (c), unshare_expr (c));
-       bsi_insert_before (bsi, new_stmt, BSI_SAME_STMT);
-       c = TREE_OPERAND (new_stmt, 0);
-     }
-
     /* If 'c' is false then FALSE_EDGE is taken.  */
     c2 = invert_truthvalue (unshare_expr (c));
     add_to_dst_predicate_list (loop, false_edge->dest, cond, c2, bsi);
--- 286,291 ----



More information about the Gcc-patches mailing list