[Mono-dev] [PATCH]: Use sparc 'sethi' in more cases.
David Miller
davem at davemloft.net
Sat Nov 3 19:15:20 EDT 2007
The Sparc code generator is too strict in it's tests
for when just a 'sethi' can be used to load a constant.
'sethi' loads the top 22-bits of a 32-bit register with the given
constant value.
This patch corrects the test, so that we use 1 instruction
instead of 2 more often.
2007-11-03 David S. Miller <davem at davemloft.net>
* sparc/sparc-codegen.h (sparc_set32, sparc_set): A plain sethi
can be used if the constant value only has the top 22 bits set.
Index: mono/arch/sparc/sparc-codegen.h
===================================================================
--- mono/arch/sparc/sparc-codegen.h (revision 88629)
+++ mono/arch/sparc/sparc-codegen.h (working copy)
@@ -855,7 +855,7 @@ typedef struct {
do { \
if ((val) == 0) \
sparc_clr_reg((ins),(reg)); \
- else if (((guint32)(val) & 0x1fff) == 0) \
+ else if (((guint32)(val) & 0x3ff) == 0) \
sparc_sethi((ins),(guint32)(val),(reg)); \
else if (((gint32)(val) >= -4096) && ((gint32)(val) <= 4095)) \
sparc_or_imm((ins),FALSE,sparc_g0,(gint32)(val),(reg)); \
@@ -883,7 +883,8 @@ typedef struct {
else if ((val >= -4096) && ((val) <= 4095)) \
sparc_or_imm((ins),FALSE,sparc_g0,bottom_word,(reg)); \
else if ((val >= 0) && (val <= 4294967295L)) { \
- sparc_sethi((ins),bottom_word,(reg)); \
+ sparc_sethi((ins),bottom_word,(reg)); \
+ if (bottom_word & 0x3ff) \
sparc_or_imm((ins),FALSE,(reg),bottom_word&0x3ff,(reg)); \
} \
else if ((val >= 0) && (val <= (1L << 44) - 1)) { \
@@ -913,7 +914,7 @@ typedef struct {
do { \
if ((val) == 0) \
sparc_clr_reg((ins),(reg)); \
- else if (((guint32)(val) & 0x1fff) == 0) \
+ else if (((guint32)(val) & 0x3ff) == 0) \
sparc_sethi((ins),(guint32)(val),(reg)); \
else if (((gint32)(val) >= -4096) && ((gint32)(val) <= 4095)) \
sparc_or_imm((ins),FALSE,sparc_g0,(gint32)(val),(reg)); \
More information about the Mono-devel-list
mailing list