* reload1.c (gen_mode_int): New function.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 8 May 1999 01:34:55 +0000 (01:34 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 8 May 1999 01:34:55 +0000 (01:34 +0000)
        (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

gcc/ChangeLog
gcc/reload1.c

index 3081ed5..1f5eda9 100644 (file)
@@ -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.
index c566d38..f16ed10 100644 (file)
@@ -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)