OSDN Git Service

2003-06-16 Aldy Hernandez <aldyh@redhat.com>
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Jun 2003 00:03:24 +0000 (00:03 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 17 Jun 2003 00:03:24 +0000 (00:03 +0000)
* simplify-rtx.c (simplify_subreg): Do not over-extend vector
constants.

* testsuite/gcc.c-torture/execute/simd-4.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68047 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/simplify-rtx.c
gcc/testsuite/gcc.c-torture/execute/simd-4.c [new file with mode: 0644]

index cf68244..132b3ab 100644 (file)
@@ -2657,6 +2657,10 @@ simplify_subreg (outermode, op, innermode, byte)
          unsigned i = BYTES_BIG_ENDIAN ? offset : offset + n_elts - 1;
          unsigned step = BYTES_BIG_ENDIAN ? 1 : -1;
          int shift = BITS_PER_UNIT * elt_size;
+         unsigned HOST_WIDE_INT unit_mask;
+
+         unit_mask = (unsigned HOST_WIDE_INT) -1
+           >> (sizeof (HOST_WIDE_INT) * BITS_PER_UNIT - shift);
 
          for (; n_elts--; i += step)
            {
@@ -2675,7 +2679,7 @@ simplify_subreg (outermode, op, innermode, byte)
              if (high >> (HOST_BITS_PER_WIDE_INT - shift))
                return NULL_RTX;
              high = high << shift | sum >> (HOST_BITS_PER_WIDE_INT - shift);
-             sum = (sum << shift) + INTVAL (elt);
+             sum = (sum << shift) + (INTVAL (elt) & unit_mask);
            }
          if (GET_MODE_BITSIZE (outermode) <= HOST_BITS_PER_WIDE_INT)
            return GEN_INT (trunc_int_for_mode (sum, outermode));
diff --git a/gcc/testsuite/gcc.c-torture/execute/simd-4.c b/gcc/testsuite/gcc.c-torture/execute/simd-4.c
new file mode 100644 (file)
index 0000000..c8ddb53
--- /dev/null
@@ -0,0 +1,16 @@
+typedef int __attribute__((vector_size(8))) v2si;
+long long s64;
+
+static inline long long
+__ev_convert_s64 (v2si a)
+{
+  return (long long) a;
+}
+
+int main()
+{
+  s64 = __ev_convert_s64 ((v2si){1,0xffffffff});
+  if (s64 != 0x1ffffffffLL)
+    abort ();
+  return 0;
+}