aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-analyze.c
diff options
context:
space:
mode:
authorDorit Nuzman <dorit@il.ibm.com>2007-09-08 09:19:39 +0000
committerDorit Nuzman <dorit@gcc.gnu.org>2007-09-08 09:19:39 +0000
commitdab1260138c4b5347270ecd535428116b2acab72 (patch)
treef6cd710146adcfeff56acdc5fb15cd95828fed1b /gcc/tree-vect-analyze.c
parentf1979d7e894829152d25f823db27aef06b518219 (diff)
downloadgcc-dab1260138c4b5347270ecd535428116b2acab72.zip
gcc-dab1260138c4b5347270ecd535428116b2acab72.tar.gz
gcc-dab1260138c4b5347270ecd535428116b2acab72.tar.bz2
re PR tree-optimization/33301 (wrong vectorization factor due to an invariant type-promotion in the loop)
PR tree-optimization/33301 * tree-vect-analyze (analyze_operations): Look at the type of the rhs when relevant. From-SVN: r128265
Diffstat (limited to 'gcc/tree-vect-analyze.c')
-rw-r--r--gcc/tree-vect-analyze.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/tree-vect-analyze.c b/gcc/tree-vect-analyze.c
index 35e38d0..a37fcf4 100644
--- a/gcc/tree-vect-analyze.c
+++ b/gcc/tree-vect-analyze.c
@@ -216,21 +216,38 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo)
}
else
{
+ tree operation;
+
gcc_assert (! STMT_VINFO_DATA_REF (stmt_info)
&& !is_pattern_stmt_p (stmt_info));
- /* We set the vectype according to the type of the result (lhs).
+ /* We generally set the vectype according to the type of the
+ result (lhs).
For stmts whose result-type is different than the type of the
arguments (e.g. demotion, promotion), vectype will be reset
appropriately (later). Note that we have to visit the smallest
datatype in this function, because that determines the VF.
If the smallest datatype in the loop is present only as the
rhs of a promotion operation - we'd miss it here.
- However, in such a case, that a variable of this datatype
- does not appear in the lhs anywhere in the loop, it shouldn't
- affect the vectorization factor. */
+ Such a case, where a variable of this datatype does not appear
+ in the lhs anywhere in the loop, can only occur if it's an
+ invariant: e.g.: 'int_x = (int) short_inv', which we'd expect
+ to have been optimized away by invariant motion. However, we
+ cannot rely on invariant motion to always take invariants out
+ of the loop, and so in the case of promotion we also have to
+ check the rhs. */
scalar_type = TREE_TYPE (GIMPLE_STMT_OPERAND (stmt, 0));
+ operation = GIMPLE_STMT_OPERAND (stmt, 1);
+ if (TREE_CODE (operation) == NOP_EXPR
+ || TREE_CODE (operation) == CONVERT_EXPR
+ || TREE_CODE (operation) == WIDEN_MULT_EXPR)
+ {
+ tree rhs_type = TREE_TYPE (TREE_OPERAND (operation, 0));
+ if (TYPE_SIZE_UNIT (rhs_type) < TYPE_SIZE_UNIT (scalar_type))
+ scalar_type = TREE_TYPE (TREE_OPERAND (operation, 0));
+ }
+
if (vect_print_dump_info (REPORT_DETAILS))
{
fprintf (vect_dump, "get vectype for scalar type: ");