OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:07:35 +0000 (14:07 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 1 Feb 2013 14:07:35 +0000 (14:07 +0000)
2013-01-03  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/55838
* loop-iv.c (iv_number_of_iterations): Call lowpart_subreg on
iv0.step, iv1.step and step.

* gcc.dg/pr55838.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@195654 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/loop-iv.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr55838.c [new file with mode: 0644]

index 6850b87..fc7abd3 100644 (file)
@@ -1,6 +1,12 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-01-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/55838
+       * loop-iv.c (iv_number_of_iterations): Call lowpart_subreg on
+       iv0.step, iv1.step and step.
+
        2012-11-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/54046
index 83d2501..5264e32 100644 (file)
@@ -2361,6 +2361,9 @@ iv_number_of_iterations (struct loop *loop, rtx insn, rtx condition,
       iv1.step = const0_rtx;
     }
 
+  iv0.step = lowpart_subreg (mode, iv0.step, comp_mode);
+  iv1.step = lowpart_subreg (mode, iv1.step, comp_mode);
+
   /* This is either infinite loop or the one that ends immediately, depending
      on initial values.  Unswitching should remove this kind of conditions.  */
   if (iv0.step == const0_rtx && iv1.step == const0_rtx)
@@ -2471,6 +2474,7 @@ iv_number_of_iterations (struct loop *loop, rtx insn, rtx condition,
        step = simplify_gen_unary (NEG, comp_mode, iv1.step, comp_mode);
       else
        step = iv0.step;
+      step = lowpart_subreg (mode, step, comp_mode);
       delta = simplify_gen_binary (MINUS, comp_mode, iv1.base, iv0.base);
       delta = lowpart_subreg (mode, delta, comp_mode);
       delta = simplify_gen_binary (UMOD, mode, delta, step);
index 6bc67e2..75d70ee 100644 (file)
@@ -1,6 +1,11 @@
 2013-02-01  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-01-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/55838
+       * gcc.dg/pr55838.c: New test.
+
        2012-12-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/55652
diff --git a/gcc/testsuite/gcc.dg/pr55838.c b/gcc/testsuite/gcc.dg/pr55838.c
new file mode 100644 (file)
index 0000000..d2d6e14
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR rtl-optimization/55838 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -funroll-loops" } */
+
+int a;
+unsigned char c;
+
+void
+f (void)
+{
+  while (c++ < 2)
+    c = a += 129;
+}