This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Vectorize if-converted loop


This patch enables vectorization of if-converted loops.

Now following loop is auto-vectorized!

  for (i = 0; i < 16; i++)
      A[i] = ( A[i] >= MAX ? MAX : 0);

This patch adds new routine vectorizable_select() to handle above loop. It uses existing APIs to create vector operands from scalar operands. Vectorized cond expr uses new VEC_COND_EXPR tree node.

VEC_COND_EXPR tree node is expanded using vcond_gen_code optab.

http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01689.html

Here expand_vec_cond_expr() is responsible for expanding VEC_COND_EXPR. expand_vec_cond_expr_p() is used by vectorizer to check vector conditional operation support on target. expand_vec_cond_expr() expands operands using standard expand_expr(). It uses is compare_from_rtx() to get comparison rtx for condition. It is handed over, along with operands rtx to vcond<mode> pattern.

Earlier I posted RS6000 patch to add vcond<mode> patterns.

http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01691.html

Here, vcond<mode> patterns use rs6000_emit_vector_cond_expr() to do the job. Appropriate vector compare insn index is selected based on condition code, destination mode and operand mode. Similarly vector select insn index is selected based on destination mode. Using these indexes and operands appropriate vector compare and select insns are emitted.

Bootstrapped and tested on powerpc-darwin.
DejaGNU and SPEC testing does not indicate any regression.
Bootstrapped on powerpc-darwin using -ftree-vectorize.

I am also including entire diff with all of these patches as ifc2.diff here.

OK?
Thank you,
-
Devang

2004-09-15 Devang Patel <dpatel@apple.com>

* tree-vectorizer.c (vectorizable_select): New function.
(vect_is_simle_cond): New function.
(vect_transform_stmt): Handle select_vec_info_type.
(vect_analyze_operations): Same.
* tree-vectorizer.h (stmt_vec_info_type): New entry select_vec_info_type.


testsuite:
        * gcc.dg/vect/vect-20040915-2.c:  New test.

Attachment: ifc2_fsf_mainline.6.0.diff
Description: Binary data



Attachment: ifc2.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]