public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-12] tree-optimization/108888 - call if-conversion
@ 2023-02-23 16:34 Andrew Stubbs
0 siblings, 0 replies; only message in thread
From: Andrew Stubbs @ 2023-02-23 16:34 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:974ca5fa871c694b71c55c4da13cc084608e0eaf
commit 974ca5fa871c694b71c55c4da13cc084608e0eaf
Author: Richard Biener <rguenther@suse.de>
Date: Thu Feb 23 11:03:03 2023 +0100
tree-optimization/108888 - call if-conversion
The following makes sure to only predicate calls necessary.
PR tree-optimization/108888
* tree-if-conv.cc (if_convertible_stmt_p): Set PLF_2 on
calls to predicate.
(predicate_statements): Only predicate calls with PLF_2.
* g++.dg/torture/pr108888.C: New testcase.
(cherry picked from commit 31cc5821223a096ef61743bff520f4a0dbba5872)
Diff:
---
gcc/ChangeLog.omp | 8 ++++++++
gcc/testsuite/ChangeLog.omp | 5 +++++
gcc/testsuite/g++.dg/torture/pr108888.C | 18 ++++++++++++++++++
gcc/tree-if-conv.cc | 17 ++++++++++-------
4 files changed, 41 insertions(+), 7 deletions(-)
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 77bc463a2c8..c1da700805c 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-02-23 Andrew Stubbs <ams@codesourcery.com>
+
+ Backport from mainline:
+ PR tree-optimization/108888
+ * tree-if-conv.cc (if_convertible_stmt_p): Set PLF_2 on
+ calls to predicate.
+ (predicate_statements): Only predicate calls with PLF_2.
+
2023-02-23 Andrew Stubbs <ams@codesourcery.com>
* internal-fn.cc (expand_MASK_CALL): New.
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index d3c93a0fd23..98e41687633 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,8 @@
+2023-02-23 Andrew Stubbs <ams@codesourcery.com>
+
+ Backport from mainline:
+ * g++.dg/torture/pr108888.C: New testcase.
+
2023-02-23 Andrew Stubbs <ams@codesourcery.com>
* gcc.dg/vect/vect-simd-clone-16.c: New test.
diff --git a/gcc/testsuite/g++.dg/torture/pr108888.C b/gcc/testsuite/g++.dg/torture/pr108888.C
new file mode 100644
index 00000000000..29a22e21102
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr108888.C
@@ -0,0 +1,18 @@
+// { dg-do compile }
+
+int scaleValueSaturate_scalefactor, scaleValueSaturate___trans_tmp_2,
+ scaleValuesSaturate_i;
+int scaleValueSaturate(int value) {
+ int result = __builtin_clz(value);
+ if (value)
+ if (-result <= scaleValueSaturate_scalefactor)
+ return 0;
+ return scaleValueSaturate___trans_tmp_2;
+}
+short scaleValuesSaturate_dst;
+short *scaleValuesSaturate_src;
+void scaleValuesSaturate() {
+ for (; scaleValuesSaturate_i; scaleValuesSaturate_i++)
+ scaleValuesSaturate_dst =
+ scaleValueSaturate(scaleValuesSaturate_src[scaleValuesSaturate_i]);
+}
diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc
index e0c2db745c1..16da1dc8df2 100644
--- a/gcc/tree-if-conv.cc
+++ b/gcc/tree-if-conv.cc
@@ -1106,6 +1106,7 @@ if_convertible_stmt_p (gimple *stmt, vec<data_reference_p> refs)
n = n->simdclone->next_clone)
if (n->simdclone->inbranch)
{
+ gimple_set_plf (stmt, GF_PLF_2, true);
need_to_predicate = true;
return true;
}
@@ -2559,7 +2560,8 @@ predicate_statements (loop_p loop)
release_defs (stmt);
continue;
}
- else if (gimple_plf (stmt, GF_PLF_2))
+ else if (gimple_plf (stmt, GF_PLF_2)
+ && is_gimple_assign (stmt))
{
tree lhs = gimple_assign_lhs (stmt);
tree mask;
@@ -2644,13 +2646,14 @@ predicate_statements (loop_p loop)
gimple_assign_set_rhs1 (stmt, ifc_temp_var (type, rhs, &gsi));
update_stmt (stmt);
}
-
- /* Convert functions that have a SIMD clone to IFN_MASK_CALL. This
- will cause the vectorizer to match the "in branch" clone variants,
- and serves to build the mask vector in a natural way. */
- gcall *call = dyn_cast <gcall *> (gsi_stmt (gsi));
- if (call && !gimple_call_internal_p (call))
+ else if (gimple_plf (stmt, GF_PLF_2)
+ && is_gimple_call (stmt))
{
+ /* Convert functions that have a SIMD clone to IFN_MASK_CALL.
+ This will cause the vectorizer to match the "in branch"
+ clone variants, and serves to build the mask vector
+ in a natural way. */
+ gcall *call = dyn_cast <gcall *> (gsi_stmt (gsi));
tree orig_fn = gimple_call_fn (call);
int orig_nargs = gimple_call_num_args (call);
auto_vec<tree> args;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-23 16:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-23 16:34 [gcc/devel/omp/gcc-12] tree-optimization/108888 - call if-conversion Andrew Stubbs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).