hoisting loop invariant loads?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

With the following code:

----------------------------
  typedef struct {
      int *scores;
      int count;
  } result;
  void sum(result *r)
  {
    int i=0,s=0;
    for (i=0;i<r->count;i++)
    {
      s += r->scores[i];
    }
  }
----------------------------

gcc 4.9.2 (x86_64, aarch64) keeps the load of the pointer r->scores inside the loop.

I am trying to get this load hoisted out of the loop. How can I achieve this?

I've tried:
  -O3
  -fgcse [ -fgcse-lm ]
  -ftree-loop-im
  -ftree-phiprop

Thanks
ranga



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux