From 72a327296948f1d5294c83e12da496b6f05b364f Mon Sep 17 00:00:00 2001 From: Kai Tietz Date: Tue, 28 Jun 2011 12:36:48 +0200 Subject: [PATCH] tree-ssa-math-opts.c (execute_optimize_bswap): Search within BB from last to first. 2011-06-28 Kai Tietz * tree-ssa-math-opts.c (execute_optimize_bswap): Search within BB from last to first. From-SVN: r175580 --- gcc/ChangeLog | 5 +++++ gcc/tree-ssa-math-opts.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2e744e89168..f655761b060 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-06-28 Kai Tietz + + * tree-ssa-math-opts.c (execute_optimize_bswap): Search + within BB from last to first. + 2011-06-28 Joseph Myers * genattr-common.c: New. Based on genattr.c. diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 4da401827f4..49ec360f9ce 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -1821,7 +1821,11 @@ execute_optimize_bswap (void) { gimple_stmt_iterator gsi; - for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + /* We do a reverse scan for bswap patterns to make sure we get the + widest match. As bswap pattern matching doesn't handle + previously inserted smaller bswap replacements as sub- + patterns, the wider variant wouldn't be detected. */ + for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) { gimple stmt = gsi_stmt (gsi); tree bswap_src, bswap_type; -- 2.30.2