Hello, this is the separated patch for issues noticed by doing type-sinking on bitwise-operations. The tests exposed that bswap pattern-matching searches from top to down for each BB. As it replaces the found match for a bswap in tree, but doesn't know about handling its inserted builtin-swap on pattern-matching for wider-mode bswap, search failed. By reversing search order within BB from last to first, this issue can be fixed.
ChangeLog 2011-06-27 Kai Tietz <kti...@redhat.com> * tree-ssa-math-opts.c (execute_optimize_bswap): Search within BB from last to first. Bootstrapped and regression-tested for x86_64-pc-linux-gnu. Ok for apply? Regards, Kai Index: gcc-head/gcc/tree-ssa-math-opts.c =================================================================== --- gcc-head.orig/gcc/tree-ssa-math-opts.c +++ gcc-head/gcc/tree-ssa-math-opts.c @@ -1820,8 +1820,10 @@ execute_optimize_bswap (void) FOR_EACH_BB (bb) { gimple_stmt_iterator gsi; - +/* for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + */ + for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) { gimple stmt = gsi_stmt (gsi); tree bswap_src, bswap_type;