Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6336791

loop unrolling of simple loop causes excessive register spilling on SPARC

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • hotspot
    • None
    • b62
    • sparc
    • solaris_10

      In the program below, the simple loop involving a few long values gets
      unrolled to the point where the generated code has a large amount of
      register spilling on SPARC. This does not occur in the OSR compilation
      of the method. The difference in performance is a factor of 10.

      When -XX:LoopUnrollLimit=0 is specified, there is no difference between
      the OSR and normal compilations, but the code is half as fast as the
      OSR compilation without this option. With -XX:LoopOptsCount=2, the
      OSR version is just as fast as without it, but the normal compilation
      is half as fast as the OSR.

      class longTest {
        
        int TOTAL = 150000000;

        double dummy; // variable used to prevent the optmizer from removing code


        public void test(int t) {
          long x = 127, dx = 0;

          for (int i = 0; i < TOTAL ; i++) {
            x -= dx;
            dx = (dx - x);
          }
          dummy = x;

        }
        public String toString(){return "long";}

        static sun.misc.Perf perf = sun.misc.Perf.getPerf();
        static long oldptime = perf.highResCounter();
        static void ptime(String msg,String suf) {
          long ptime = perf.highResCounter();
          if (msg != null) {
            System.out.print(msg +
                               ( ( (float) (((double)(ptime - oldptime)) /
                                perf.highResFrequency())))+suf);
          }
          oldptime = ptime;
        }

        static public void main(String args[]) {
          longTest lt = new longTest();

          for (int i = 0; i < 5; i++) {
            lt.ptime(null, null);
            lt.test(0);
            lt.ptime(lt.toString() + " ", "\n");
          }
        }
      };

            rknippelsunw Ross Knippel (Inactive)
            sdeversunw Steve Dever (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: