This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] s390: optimize special compare
- From: Andreas Krebbel <krebbel1 at de dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Feb 2004 14:15:16 +0100
- Subject: [patch] s390: optimize special compare
- Organization: IBM Entwicklung GmbH
- Reply-to: Andreas dot Krebbel at web dot de
Hello,
the attached patch uses the CANONICALIZE_COMPARISON macro in order to modify
a comparison rtx after simplification. The modification is performed on a HImode
compare with a full bitmask. In this special case the s390 can use the tml (test under mask)
instruction with 0xFFFF as an immediate. Otherwise the backend would have to store the
immediate in the literal pool.
And yes, I know that the macro is intended to be used in case of unsupported compares
whereas I've used it to turn a "badly supported" compare into a better supported one.
But this optimization is important for several test cases and I didn't know about a better
solution.
Bootstrapped and regtested on s390-ibm-linux and s390x-ibm-linux.
OK?
-Andreas-
2004-02-18 Andreas Krebbel <krebbel1@de.ibm.com>
* config/s390/s390.h (CANONICALIZE_COMPARISON): Macro definition added.
Index: gcc/config/s390/s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.99
diff -p -c -r1.99 s390.h
*** gcc/config/s390/s390.h 7 Feb 2004 17:06:22 -0000 1.99
--- gcc/config/s390/s390.h 9 Feb 2004 12:37:12 -0000
*************** do { \
*** 1035,1038 ****
--- 1035,1053 ----
/* This macro definition sets up a default value for `main' to return. */
#define DEFAULT_MAIN_RETURN c_expand_return (integer_zero_node)
+ /* This macro is used by simplify_comparison to allow platform dependent
+ canonicalization of the simplified compare rtx. It is somehow misused here
+ in order to truncate comparisons from a wider mode to HImode to make use
+ of the "*tmhi_full" insn pattern. */
+ #define CANONICALIZE_COMPARISON(CODE, OP0, OP1) \
+ if (REG_P(OP0) && GET_CODE(OP1) == CONST_INT) \
+ { \
+ if (nonzero_bits (OP0, GET_MODE(OP0)) == GET_MODE_MASK(HImode) \
+ && (unsigned HOST_WIDE_INT)INTVAL(OP1) == GET_MODE_MASK(HImode)) \
+ { \
+ OP0 = gen_lowpart_for_combine(HImode, OP0); \
+ OP1 = GEN_INT (trunc_int_for_mode (INTVAL(OP1), HImode)); \
+ } \
+ }
+
#endif