The following patch enables bswap-from-load for STRICT_ALIGNMENT targets when the load is aligned instead of unconditionally (which probably was not intended).
(note to self: we should fully transition to use SLOW_UNALIGNED_ACCESS) Bootstrapped and tested on x86_64-unknown-linux-gnu. Richard. 2014-06-27 Richard Biener <rguent...@suse.de> * tree-ssa-math-opts.c (bswap_replace): Fix SLOW_UNALIGNED_ACCESS test to only apply to unaligned object. Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c (revision 212064) +++ gcc/tree-ssa-math-opts.c (working copy) @@ -2179,7 +2179,9 @@ bswap_replace (gimple cur_stmt, gimple_s unsigned align; align = get_object_alignment (src); - if (bswap && SLOW_UNALIGNED_ACCESS (TYPE_MODE (load_type), align)) + if (bswap + && align < GET_MODE_ALIGNMENT (TYPE_MODE (load_type)) + && SLOW_UNALIGNED_ACCESS (TYPE_MODE (load_type), align)) return false; gsi_move_before (&gsi, &gsi_ins);