Zero extend when generating a CONST_DOUBLE in convert_modes
authorIan Lance Taylor <ian@gcc.gnu.org>
Sun, 27 Oct 1996 02:08:23 +0000 (02:08 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sun, 27 Oct 1996 02:08:23 +0000 (02:08 +0000)
From-SVN: r13041

gcc/expr.c

index 37950e9bc20e3e98edb07875e7804070d4e260d1..abdfba723050deca4b2745c794808b5f0aacbbd7 100644 (file)
@@ -1292,7 +1292,20 @@ convert_modes (mode, oldmode, x, unsignedp)
   if (unsignedp && GET_MODE_CLASS (mode) == MODE_INT
       && GET_MODE_BITSIZE (mode) == 2 * HOST_BITS_PER_WIDE_INT
       && GET_CODE (x) == CONST_INT && INTVAL (x) < 0)
-    return immed_double_const (INTVAL (x), (HOST_WIDE_INT) 0, mode);
+    {
+      HOST_WIDE_INT val = INTVAL (x);
+
+      if (oldmode != VOIDmode
+         && HOST_BITS_PER_WIDE_INT > GET_MODE_BITSIZE (oldmode))
+       {
+         int width = GET_MODE_BITSIZE (oldmode);
+
+         /* We need to zero extend VAL.  */
+         val &= ((HOST_WIDE_INT) 1 << width) - 1;
+       }
+
+      return immed_double_const (val, (HOST_WIDE_INT) 0, mode);
+    }
 
   /* We can do this with a gen_lowpart if both desired and current modes
      are integer, and this is either a constant integer, a register, or a