summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>1999-05-08 01:34:55 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>1999-05-08 01:34:55 +0000
commit886ccd9a3d2721d4cd88ab3e051bf07257e1d1e1 (patch)
tree68b9ea358e14d47ebe5bf789990ddda92faa07d0 /gcc
parent785f5424fc86e7d04f8230a198645aa0b535ea0f (diff)
downloadgcc-886ccd9a3d2721d4cd88ab3e051bf07257e1d1e1.tar.gz
* reload1.c (gen_mode_int): New function.
(reload_cse_move2add): Use it to generate the new constants. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@26834 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/reload1.c29
2 files changed, 30 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3081ed59d60..1f5eda9c25f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+Sat May 8 01:34:19 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
+
+ * reload1.c (gen_mode_int): New function.
+ (reload_cse_move2add): Use it to generate the new constants.
+
Sat May 8 01:25:09 1999 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
* varasm.c (output_constant): Do nothing if -fsyntax-only.
diff --git a/gcc/reload1.c b/gcc/reload1.c
index c566d3819d0..f16ed109875 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -9962,6 +9962,24 @@ static enum machine_mode reg_mode[FIRST_PSEUDO_REGISTER];
reload_cse_move2add and move2add_note_store. */
static int move2add_luid;
+/* Generate a CONST_INT and force it in the range of MODE. */
+static rtx
+gen_mode_int (mode, value)
+ enum machine_mode mode;
+ HOST_WIDE_INT value;
+{
+ HOST_WIDE_INT cval = value & GET_MODE_MASK (mode);
+ int width = GET_MODE_BITSIZE (mode);
+
+ /* If MODE is narrower than HOST_WIDE_INT and CVAL is a negative number,
+ sign extend it. */
+ if (width > 0 && width < HOST_BITS_PER_WIDE_INT
+ && (cval & ((HOST_WIDE_INT) 1 << (width - 1))) != 0)
+ cval |= (HOST_WIDE_INT) -1 << width;
+
+ return GEN_INT (cval);
+}
+
static void
reload_cse_move2add (first)
rtx first;
@@ -10013,8 +10031,9 @@ reload_cse_move2add (first)
if (GET_CODE (src) == CONST_INT && reg_base_reg[regno] < 0)
{
int success = 0;
- rtx new_src = GEN_INT (INTVAL (src)
- - INTVAL (reg_offset[regno]));
+ rtx new_src
+ = gen_mode_int (GET_MODE (reg),
+ INTVAL (src) - INTVAL (reg_offset[regno]));
/* (set (reg) (plus (reg) (const_int 0))) is not canonical;
use (set (reg) (reg)) instead.
We don't delete this insn, nor do we convert it into a
@@ -10059,8 +10078,10 @@ reload_cse_move2add (first)
&& GET_CODE (XEXP (SET_SRC (set), 1)) == CONST_INT)
{
rtx src3 = XEXP (SET_SRC (set), 1);
- rtx new_src = GEN_INT (INTVAL (src3)
- - INTVAL (reg_offset[regno]));
+ rtx new_src
+ = gen_mode_int (GET_MODE (reg),
+ INTVAL (src3)
+ - INTVAL (reg_offset[regno]));
int success = 0;
if (new_src == const0_rtx)