[gcc(refs/vendors/ventana/heads/minor-improvements-for-gcc11)] bswap: recognize bswap32, even if only an opcode for bswap64 exists

Philipp Tomsich ptomsich@gcc.gnu.org
Mon Jan 4 17:01:18 GMT 2021


https://gcc.gnu.org/g:1ca2420a82d2aa16edcc770a155cfe888e6e8968

commit 1ca2420a82d2aa16edcc770a155cfe888e6e8968
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Fri Dec 18 16:14:13 2020 +0100

    bswap: recognize bswap32, even if only an opcode for bswap64 exists
    
    While the RTL expander in optabs knows that a 32bit bswap can be
    synthesized from a 64bit bswap (in widen_bswap) opcode, the bswap pass
    does exclude opportunities for bswap32 if no opcode is present.  This
    change teaches the pass that it should also work on opportunities for
    a bswap32, if only an opcode for bswap64 exists.
    
    gcc/ChangeLog:
    
            * gimple-ssa-store-merging.c (pass_optimize_bswap::execute):
            Modify the bswap32_p predicate computation to consider the
            case where a bswap32 is synthesized from a bswap64-opcode
            (followed by a logical or arithmetic shift).

Diff:
---
 gcc/gimple-ssa-store-merging.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index 4279c605d32..d034180a85c 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -1271,7 +1271,8 @@ pass_optimize_bswap::execute (function *fun)
   tree bswap32_type = NULL_TREE, bswap64_type = NULL_TREE;
 
   bswap32_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
-	       && optab_handler (bswap_optab, SImode) != CODE_FOR_nothing);
+	       && (optab_handler (bswap_optab, SImode) != CODE_FOR_nothing
+		   || optab_handler (bswap_optab, DImode) != CODE_FOR_nothing));
   bswap64_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
 	       && (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing
 		   || (bswap32_p && word_mode == SImode)));


More information about the Gcc-cvs mailing list