summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-30 15:07:20 +0000
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>2017-10-30 15:07:20 +0000
commitcfb1beeeeabd673ec44feed78206f345300686fa (patch)
tree61cd99f7f20374930f9d8c0eda7c72268f2e331f
parent4fc74ab57a82290e81a37041fd1c5a9be34f9481 (diff)
downloadgcc-cfb1beeeeabd673ec44feed78206f345300686fa.tar.gz
[hsa] Add missing guard in OMP gridification
2017-10-30 Martin Jambor <mjambor@suse.cz> * omp-grid.c (grid_attempt_target_gridification): Also insert a condition whether loop should be executed at all. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254225 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/omp-grid.c2
2 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c690e338484..8710e29f51a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2017-10-30 Martin Jambor <mjambor@suse.cz>
+
+ * omp-grid.c (grid_attempt_target_gridification): Also insert a
+ condition whether loop should be executed at all.
+
2017-10-30 Will Schmidt <will_schmidt@vnet.ibm.com>
* config/rs6000/rs6000.c (rs6000_gimple_fold_builtin): Add support for
diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c
index a7b6f60aeaf..121c96ebe39 100644
--- a/gcc/omp-grid.c
+++ b/gcc/omp-grid.c
@@ -1315,6 +1315,7 @@ grid_attempt_target_gridification (gomp_target *target,
n1 = fold_convert (itype, n1);
n2 = fold_convert (itype, n2);
+ tree cond = fold_build2 (cond_code, boolean_type_node, n1, n2);
tree step
= omp_get_for_step_from_incr (loc, gimple_omp_for_incr (inner_loop, i));
@@ -1328,6 +1329,7 @@ grid_attempt_target_gridification (gomp_target *target,
fold_build1 (NEGATE_EXPR, itype, step));
else
t = fold_build2 (TRUNC_DIV_EXPR, itype, t, step);
+ t = fold_build3 (COND_EXPR, itype, cond, t, build_zero_cst (itype));
if (grid.tiling)
{
if (cond_code == GT_EXPR)