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

[c2] No need to convert "(x+1)+y" into "(x+y)+1" when y is a CallNode

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 23
    • hotspot

      For a java code:

      long tmp = val + 3;
      long ret = callNoInlineMethod() + tmp;

      the result of an ideal graph like this:

       25 LoadL === _ 7 24 [[ 27 53 ]] #val
       26 ConL === 0 [[ 52 27 ]] #var:3
       27 AddL === _ 25 26 [[ 37 ]]
       37 CallStaticJava === 5 6 7 8 1 (10 1 27 1 ) [[ 38 39 40 42 ]] #callNoInlineMethod
       42 Proj === 37 [[ 53 ]]
       52 AddL === _ 53 26 [[ 54 ]]
       53 AddL === _ 42 25 [[ 52 ]]

      Three AddL nodes have been generated here, actually, two AddL nodes should be sufficient, and "25 LoadL", "26 ConL", "27 AddL" all need to be saved on the stack before call "callNoInlineMethod()". A reasonable ideal graph should be:
       
       25 LoadL === _ 7 24 [[ 27 ]] #val
       26 ConL === 0 [[ 27 ]] #var:3
       27 AddL === _ 25 26 [[ 37 ]]
       37 CallStaticJava === 5 6 7 8 1 (10 1 27 1 ) [[ 38 39 40 42 ]] #callNoInlineMethod
       42 Proj === 37 [[ 53 ]]
       53 AddL === _ 42 27 [[ .. ]]

      Here, only "27 AddL" need to be saved to stack and two AddL nodes is sufficient.

            sguoyun Sun Guoyun
            sguoyun Sun Guoyun
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: