x * x computes wrong value in strictfp mode

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 6
    • Affects Version/s: 6
    • Component/s: hotspot
    • None
    • b46
    • sparc
    • solaris_9

      There appears to be a longstanding problem with strict multiplies in C2. It looks like the rule for strict multiplies doesn't work right if src == dst. Here's a test case:

      public class strictsqr {
          static strictfp double strictsqr(double x) {
              return x*x;
          }

          final static int limit = 10000000;
          public static void main(String[] args) {
              for (int i = 0; i < 20; i ++) {
                  double x = i / (double)limit;
                  System.out.println(strictsqr.strictsqr(x));
              }
          }
      }

      java -server -XX:UseSSE=0 -Xcomp strictsqr will output all zeros instead of the correct output in which only the first value is zero. This fails all the way back to 1.4.2.

            Assignee:
            Azeem Jiva
            Reporter:
            Tom Rodriguez
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: