* tree-chrec.c (chrec_convert_1): Only fold (T2)(t +- x) to
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Dec 2009 12:47:40 +0000 (12:47 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Dec 2009 12:47:40 +0000 (12:47 +0000)
(T2)t +- (T2)x if only integer types are involved.

* gcc.c-torture/compile/20091215-1.c: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20091215-1.c [new file with mode: 0644]
gcc/tree-chrec.c

index f3958e6..b774fa3 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-chrec.c (chrec_convert_1): Only fold (T2)(t +- x) to
+       (T2)t +- (T2)x if only integer types are involved.
+
 2009-12-16  Ben Elliston  <bje@au.ibm.com>
 
        * tree-data-ref.h (dot_rdg): Remove prototype.
index 7f650de..d0c0985 100644 (file)
@@ -1,5 +1,7 @@
 2009-12-16  Jakub Jelinek  <jakub@redhat.com>
 
+       * gcc.c-torture/compile/20091215-1.c: New test.
+
        * gcc.dg/debug/tls-1.c: New test.
 
 2009-12-15  Jason Merrill  <jason@redhat.com>
diff --git a/gcc/testsuite/gcc.c-torture/compile/20091215-1.c b/gcc/testsuite/gcc.c-torture/compile/20091215-1.c
new file mode 100644 (file)
index 0000000..7862e2f
--- /dev/null
@@ -0,0 +1,15 @@
+void bar ();
+
+void
+foo (void *x, short y)
+{
+  bar (x, y + 1);
+}
+
+void
+bar (x, y)
+  void *x;
+  char *y;
+{
+  baz (y);
+}
index 9711e20..18ed4ed 100644 (file)
@@ -1293,6 +1293,8 @@ keep_cast:
   if (use_overflow_semantics
       && (TREE_CODE (chrec) == PLUS_EXPR
          || TREE_CODE (chrec) == MINUS_EXPR)
+      && TREE_CODE (type) == INTEGER_TYPE
+      && TREE_CODE (ct) == INTEGER_TYPE
       && TYPE_PRECISION (type) > TYPE_PRECISION (ct)
       && TYPE_OVERFLOW_UNDEFINED (ct))
     res = fold_build2 (TREE_CODE (chrec), type,