avr-related reload fix from Senthil Kumar Selvaraj
authorBernd Schmidt <bernds@gcc.gnu.org>
Fri, 29 Apr 2016 08:59:09 +0000 (08:59 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Fri, 29 Apr 2016 08:59:09 +0000 (08:59 +0000)
PR target/60040
* reload1.c (reload): Call finish_spills before
restarting reload loop. Skip select_reload_regs
if update_eliminables_and_spill returns true.

testsuite/
PR target/60040
* gcc.target/avr/pr60040-1.c: New.
* gcc.target/avr/pr60040-2.c: New.

From-SVN: r235625

gcc/ChangeLog
gcc/reload1.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/avr/pr60040-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/avr/pr60040-2.c [new file with mode: 0644]

index a92fd768eeeb3fd660f5a473fc17c73574ef03c5..0ed967ce77a2eb56db3dec994631ece0b8c27a77 100644 (file)
@@ -1,3 +1,10 @@
+2016-04-29  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       PR target/60040
+       * reload1.c (reload): Call finish_spills before
+       restarting reload loop. Skip select_reload_regs
+       if update_eliminables_and_spill returns true.
+
 2016-04-29  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * config/arc/arc.h (UNSIGNED_INT12, UNSIGNED_INT16): Define.
index c2800f8cb790ed221123c64c6697166d93dc7984..d6fcece1b7338614032f47e5b4ae50e892d0c9ca 100644 (file)
@@ -981,7 +981,8 @@ reload (rtx_insn *first, int global)
       /* If we allocated another stack slot, redo elimination bookkeeping.  */
       if (something_was_spilled || starting_frame_size != get_frame_size ())
        {
-         update_eliminables_and_spill ();
+         if (update_eliminables_and_spill ())
+           finish_spills (global);
          continue;
        }
 
@@ -1021,10 +1022,12 @@ reload (rtx_insn *first, int global)
          did_spill = 1;
          something_changed = 1;
        }
-
-      select_reload_regs ();
-      if (failure)
-       goto failed;
+      else
+       {
+         select_reload_regs ();
+         if (failure)
+           goto failed;
+       }
 
       if (insns_need_reload != 0 || did_spill)
        something_changed |= finish_spills (global);
index 860e343fbe146dc0b5c01112bc00d3dcb0d63935..e6850db9ef665ed70764fe2c967770e3c8a0c728 100644 (file)
@@ -1,3 +1,11 @@
+2016-04-29  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+           Matthijs Kooijman  <matthijs@stdin.nl>
+           Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>
+
+       PR target/60040
+       * gcc.target/avr/pr60040-1.c: New.
+       * gcc.target/avr/pr60040-2.c: New.
+
 2016-04-29  Richard Biener  <rguenther@suse.de>
 
        * gcc.dg/tree-ssa/pr18589-10.c: Adjust.
diff --git a/gcc/testsuite/gcc.target/avr/pr60040-1.c b/gcc/testsuite/gcc.target/avr/pr60040-1.c
new file mode 100644 (file)
index 0000000..4fe296b
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+float dhistory[10];
+float test;
+
+float getSlope(float history[]) {
+  float sumx = 0;
+  float sumy = 0;
+  float sumxy = 0;
+  float sumxsq = 0;
+  float rate = 0;
+  int n = 10;
+
+  int i;
+  for (i=1; i< 11; i++) {
+    sumx = sumx + i;
+    sumy = sumy + history[i-1];
+    sumy = sumy + history[i-1];
+    sumxsq = sumxsq + (i*i);
+  }
+
+  rate = sumy+sumx+sumxsq;
+  return rate;
+}
+
+void loop() {
+  test = getSlope(dhistory);
+}
diff --git a/gcc/testsuite/gcc.target/avr/pr60040-2.c b/gcc/testsuite/gcc.target/avr/pr60040-2.c
new file mode 100644 (file)
index 0000000..c40d49f
--- /dev/null
@@ -0,0 +1,112 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+typedef unsigned char __uint8_t;
+typedef short unsigned int __uint16_t;
+typedef long unsigned int __uint32_t;
+typedef __uint8_t uint8_t ;
+typedef __uint16_t uint16_t ;
+typedef __uint32_t uint32_t ;
+typedef __builtin_va_list __gnuc_va_list;
+typedef __gnuc_va_list va_list;
+typedef enum rtems_blkdev_request_op {
+  RTEMS_BLKDEV_REQ_READ,
+} rtems_fdisk_segment_desc;
+typedef struct rtems_fdisk_driver_handlers
+{
+  int (*blank) (const rtems_fdisk_segment_desc* sd,
+                uint32_t device,
+                uint32_t segment,
+                uint32_t offset,
+                uint32_t size);
+} rtems_fdisk_driver_handlers;
+typedef struct rtems_fdisk_page_desc
+{
+  uint16_t flags;
+  uint32_t block;
+} rtems_fdisk_page_desc;
+typedef struct rtems_fdisk_segment_ctl
+{
+  rtems_fdisk_page_desc* page_descriptors;
+  uint32_t pages_active;
+} rtems_fdisk_segment_ctl;
+typedef struct rtems_fdisk_segment_ctl_queue
+{
+} rtems_fdisk_segment_ctl_queue;
+typedef struct rtems_fdisk_device_ctl
+{
+  uint32_t flags;
+  uint8_t* copy_buffer;
+} rtems_flashdisk;
+
+extern void rtems_fdisk_error (const char *, ...);
+extern int rtems_fdisk_seg_write(const rtems_flashdisk*,
+                                 rtems_fdisk_segment_ctl*,
+                                 uint32_t,
+                                 const rtems_fdisk_page_desc* page_desc,
+                                uint32_t);
+
+void rtems_fdisk_printf (const rtems_flashdisk* fd, const char *format, ...)
+{
+  {
+    va_list args;
+    __builtin_va_start(args,format);
+  }
+}
+static int
+rtems_fdisk_seg_blank_check (const rtems_flashdisk* fd,
+                             rtems_fdisk_segment_ctl* sc,
+                             uint32_t offset,
+                             uint32_t size)
+{
+  uint32_t device;
+  uint32_t segment;
+  const rtems_fdisk_segment_desc* sd;
+  const rtems_fdisk_driver_handlers* ops;
+  return ops->blank (sd, device, segment, offset, size);
+}
+static int
+rtems_fdisk_seg_write_page_desc (const rtems_flashdisk* fd,
+                                 rtems_fdisk_segment_ctl* sc,
+                                 uint32_t page,
+                                 const rtems_fdisk_page_desc* page_desc)
+{
+  uint32_t offset = page * sizeof (rtems_fdisk_page_desc);
+  if ((fd->flags & (1 << 3)))
+  {
+    int ret = rtems_fdisk_seg_blank_check (fd, sc,
+                                           offset,
+                                           sizeof (rtems_fdisk_page_desc));
+  }
+  return rtems_fdisk_seg_write (fd, sc, offset,
+                                page_desc, sizeof (rtems_fdisk_page_desc));
+}
+void
+rtems_fdisk_recycle_segment (rtems_flashdisk* fd,
+                                    rtems_fdisk_segment_ctl* ssc,
+                                    rtems_fdisk_segment_ctl* dsc,
+                                    uint32_t *pages)
+{
+  int ret;
+  uint32_t spage;
+  uint32_t used = 0;
+  uint32_t active = 0;
+  {
+    rtems_fdisk_page_desc* spd = &ssc->page_descriptors[spage];
+    {
+      rtems_fdisk_page_desc* dpd;
+      uint32_t dpage;
+      dpd = &dsc->page_descriptors[dpage];
+      *dpd = *spd;
+      ret = rtems_fdisk_seg_write_page_desc (fd,
+                                             dsc,
+                                             dpage, dpd);
+    }
+  }
+  rtems_fdisk_printf (fd, "ssc end: %d-%d: p=%ld, a=%ld, u=%ld",
+                      pages, active, used);
+  {
+    rtems_fdisk_error ("compacting: ssc pages not 0: %d",
+                       ssc->pages_active);
+  }
+}