* [PATCH] CSE if-converted loop bodies
@ 2018-10-25 13:29 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2018-10-25 13:29 UTC (permalink / raw)
To: gcc-patches
if-conversion can leave us with quite a mess, esp. redundant loads.
This confuses vectorizer data-ref analysis enough to be worth
fixing. So the following patch runs RPO VN on the loop body.
PR87746 contains some before/after dumps.
Now we only need to teach it some simple DSE...
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard.
2018-10-25 Richard Biener <rguenther@suse.de>
* tree-if-conv.c: Include tree-ssa-sccvn.h.
(tree_if_conversion): Run CSE on the if-converted loop body.
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 52aa5756c94..0ef7daa49e8 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -118,6 +118,7 @@ along with GCC; see the file COPYING3. If not see
#include "cfganal.h"
#include "internal-fn.h"
#include "fold-const.h"
+#include "tree-ssa-sccvn.h"
/* Only handle PHIs with no more arguments unless we are asked to by
simd pragma. */
@@ -2979,6 +2980,7 @@ tree_if_conversion (struct loop *loop)
unsigned int todo = 0;
bool aggressive_if_conv;
struct loop *rloop;
+ bitmap exit_bbs;
again:
rloop = NULL;
@@ -3056,6 +3058,14 @@ tree_if_conversion (struct loop *loop)
/* Delete dead predicate computations. */
ifcvt_local_dce (loop->header);
+ /* Perform local CSE, this esp. helps the vectorizer analysis if loads
+ and stores are involved.
+ ??? We'll still keep dead stores though. */
+ exit_bbs = BITMAP_ALLOC (NULL);
+ bitmap_set_bit (exit_bbs, single_exit (loop)->dest->index);
+ todo |= do_rpo_vn (cfun, loop_preheader_edge (loop), exit_bbs);
+ BITMAP_FREE (exit_bbs);
+
todo |= TODO_cleanup_cfg;
cleanup:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-10-25 12:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 13:29 [PATCH] CSE if-converted loop bodies Richard Biener
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).