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

Absolute value check for float/double doesn't work

    XMLWordPrintable

Details

    • Enhancement
    • Status: Resolved
    • P4
    • Resolution: Won't Fix
    • 15
    • tbd
    • hotspot
    • generic
    • generic

    Description

      There is absolute value check for float/double.
      http://hg.openjdk.java.net/jdk/jdk/file/dd652a1b2a39/src/hotspot/share/opto/cfgnode.cpp#l1519

      But it doesn't work both on AArch64 and x86.

      Test case:

        public static float absf(float a) {
                return ((a <= 0.0f) ? 0.0f - a : a);
        }

      Assembly generated by c2 on AArch64:
      0x0000ffff8cb3c054: fmov s17, wzr
      0x0000ffff8cb3c058: fcmp s17, s0
      0x0000ffff8cb3c05c: b.lt 0x0000ffff8cb3c078
      0x0000ffff8cb3c060: fsub s0, s17, s0
      0x0000ffff8cb3c078: fcmp s17, s0
      0x0000ffff8cb3c07c: csetm w10, ne // ne = any
      0x0000ffff8cb3c080: cneg w10, w10, ge // ge = tcont

      In this code snippet, pattern CmpF3 is matched. But it isn't expected.

      We expect that pattern AbsF can be matched.
      For example, Math.abs(float) is used.

        public static float absfm(float a) {
                return Math.abs(a);
        }

      Assembly generated by c2 on AArch64:
      0x0000ffff80b3c0d4: fabs s0, s0

      Attachments

        Issue Links

          Activity

            People

              yzhang Yang Zhang
              yzhang Yang Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: