summaryrefslogtreecommitdiff
path: root/gcc/graphite-sese-to-poly.c
diff options
context:
space:
mode:
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-24 20:55:22 +0000
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2015-07-24 20:55:22 +0000
commit8372922455e859bd7ad5771a74315cb7308eb368 (patch)
tree4b8350baf0dc6269f524db5a85b88dd0a48113aa /gcc/graphite-sese-to-poly.c
parent9e96f1e1b9731c4e1ef4fbbbf0997319973f0537 (diff)
downloadgcc-8372922455e859bd7ad5771a74315cb7308eb368.tar.gz
Don't allow unsafe reductions in graphite
2015-07-24 Tom de Vries <tom@codesourcery.com> * graphite-sese-to-poly.c (is_reduction_operation_p): Limit flag_associative_math to FLOAT_TYPE_P. Honour TYPE_OVERFLOW_WRAPS for INTEGRAL_TYPE_P. Don't allow any other types. * gcc.dg/graphite/block-1.c: Xfail scan. * gcc.dg/graphite/interchange-12.c: Same. * gcc.dg/graphite/interchange-14.c: Same. * gcc.dg/graphite/interchange-15.c: Same. * gcc.dg/graphite/interchange-9.c: Same. * gcc.dg/graphite/interchange-mvt.c: Same. * gcc.dg/graphite/uns-block-1.c: New test. * gcc.dg/graphite/uns-interchange-12.c: New test. * gcc.dg/graphite/uns-interchange-14.c: New test. * gcc.dg/graphite/uns-interchange-15.c: New test. * gcc.dg/graphite/uns-interchange-9.c: New test. * gcc.dg/graphite/uns-interchange-mvt.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@226193 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/graphite-sese-to-poly.c')
-rw-r--r--gcc/graphite-sese-to-poly.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c
index 47944f0c3ee..25cfa17b948 100644
--- a/gcc/graphite-sese-to-poly.c
+++ b/gcc/graphite-sese-to-poly.c
@@ -2605,9 +2605,17 @@ is_reduction_operation_p (gimple stmt)
gcc_assert (is_gimple_assign (stmt));
code = gimple_assign_rhs_code (stmt);
- return flag_associative_math
- && commutative_tree_code (code)
- && associative_tree_code (code);
+ if (!commutative_tree_code (code)
+ || !associative_tree_code (code))
+ return false;
+
+ tree type = TREE_TYPE (gimple_assign_lhs (stmt));
+
+ if (FLOAT_TYPE_P (type))
+ return flag_associative_math;
+
+ return (INTEGRAL_TYPE_P (type)
+ && TYPE_OVERFLOW_WRAPS (type));
}
/* Returns true when PHI contains an argument ARG. */