This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[m68k] Fix use of exact_log2 on CONST_INT values
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 May 2009 17:37:18 +0200
- Subject: [m68k] Fix use of exact_log2 on CONST_INT values
Since CONST_INTs are sign extended we have to mask off the sign bit
copies before calling exact_log2, in case HWI is larger than 32 bits.
Andreas.
2009-05-18 Andreas Schwab <schwab@linux-m68k.org>
PR target/39531
* config/m68k/m68k.c (output_andsi3): Mask off sign bit copies
before calling exact_log2.
(output_iorsi3): Likewise.
(output_xorsi3): Likewise.
Index: config/m68k/m68k.c
===================================================================
--- config/m68k/m68k.c (revision 147662)
+++ config/m68k/m68k.c (working copy)
@@ -4829,7 +4829,7 @@ output_andsi3 (rtx *operands)
return "and%.w %2,%0";
}
if (GET_CODE (operands[2]) == CONST_INT
- && (logval = exact_log2 (~ INTVAL (operands[2]))) >= 0
+ && (logval = exact_log2 (~ INTVAL (operands[2]) & 0xffffffff)) >= 0
&& (DATA_REG_P (operands[0])
|| offsettable_memref_p (operands[0])))
{
@@ -4866,7 +4866,7 @@ output_iorsi3 (rtx *operands)
return "or%.w %2,%0";
}
if (GET_CODE (operands[2]) == CONST_INT
- && (logval = exact_log2 (INTVAL (operands[2]))) >= 0
+ && (logval = exact_log2 (INTVAL (operands[2]) & 0xffffffff)) >= 0
&& (DATA_REG_P (operands[0])
|| offsettable_memref_p (operands[0])))
{
@@ -4901,7 +4901,7 @@ output_xorsi3 (rtx *operands)
return "eor%.w %2,%0";
}
if (GET_CODE (operands[2]) == CONST_INT
- && (logval = exact_log2 (INTVAL (operands[2]))) >= 0
+ && (logval = exact_log2 (INTVAL (operands[2]) & 0xffffffff)) >= 0
&& (DATA_REG_P (operands[0])
|| offsettable_memref_p (operands[0])))
{
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."