You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Alexey Varlamov (JIRA)" <ji...@apache.org> on 2008/07/01 13:59:45 UTC

[jira] Created: (HARMONY-5887) [drlvm][jitrino] use INC operation to increment profile

[drlvm][jitrino] use INC operation to increment profile 
--------------------------------------------------------

                 Key: HARMONY-5887
                 URL: https://issues.apache.org/jira/browse/HARMONY-5887
             Project: Harmony
          Issue Type: Improvement
          Components: DRLVM
            Reporter: Alexey Varlamov
            Priority: Trivial


I've noticed "ADD counter,1" construct is used to increment dynamic profile counters. More neat and efective INC instruction should be used instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (HARMONY-5887) [drlvm][jitrino] use INC operation to increment profile

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Varlamov closed HARMONY-5887.
------------------------------------

    Resolution: Invalid

Thanks for the exhaustive evaluation, Alexey! 
PS. I wonder if there any point to use INC ever, then (other than binary code size).

> [drlvm][jitrino] use INC operation to increment profile 
> --------------------------------------------------------
>
>                 Key: HARMONY-5887
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5887
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Alexey Varlamov
>            Priority: Trivial
>         Attachments: inc.diff
>
>
> I've noticed "ADD counter,1" construct is used to increment dynamic profile counters. More neat and efective INC instruction should be used instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5887) [drlvm][jitrino] use INC operation to increment profile

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609640#action_12609640 ] 

Aleksey Shipilev commented on HARMONY-5887:
-------------------------------------------

On my P4 2.8 Ghz (Northwood) / Gentoo Linux and this microtest:

$ gcc -DADD test.c && time ./a.out
real    0m3.581s
user    0m3.580s
sys     0m0.001s

$ gcc -DINC test.c && time ./a.out
real    0m5.729s
user    0m5.701s
sys     0m0.011s

This one proofs the Optimization Manual's coding rule: use ADD instead of INC.

---- test.c -------------------------------------------------

static const int count = -1024;

int main(int argc, char** argv) {

        #ifdef ADD
        asm (
                "movl $count, %eax\t\n"
                "movl $count, %ebx\t\n"
                "movl $count, %ecx\t\n"
                "movl $count, %edx\t\n"
                "loop: addl $1, %eax\t\n"
                "addl $1, %ebx\t\n"
                "addl $1, %ecx\t\n"
                "addl $1, %edx\t\n"
                "addl $1, %eax\t\n"
                "addl $1, %ebx\t\n"
                "addl $1, %ecx\t\n"
                "addl $1, %edx\t\n"
                "testl %eax, %eax\t\n"
                "jne loop\t\n"
        );
        #endif

        #ifdef INC
        asm (
                "movl $count, %eax\t\n"
                "movl $count, %ebx\t\n"
                "movl $count, %ecx\t\n"
                "movl $count, %edx\t\n"
                "loop: incl %eax\t\n"
                "incl %ebx\t\n"
                "incl %ecx\t\n"
                "incl %edx\t\n"
                "incl %eax\t\n"
                "incl %ebx\t\n"
                "incl %ecx\t\n"
                "incl %edx\t\n"
                "testl %eax, %eax\t\n"
                "jne loop\t\n"
        );
        #endif

        return 0;
}

---- test.c (end) --------------------------------------------

> [drlvm][jitrino] use INC operation to increment profile 
> --------------------------------------------------------
>
>                 Key: HARMONY-5887
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5887
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Alexey Varlamov
>            Priority: Trivial
>         Attachments: inc.diff
>
>
> I've noticed "ADD counter,1" construct is used to increment dynamic profile counters. More neat and efective INC instruction should be used instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (HARMONY-5887) [drlvm][jitrino] use INC operation to increment profile

Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-5887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexey Varlamov updated HARMONY-5887:
-------------------------------------

    Attachment: inc.diff

patch is not tested.

> [drlvm][jitrino] use INC operation to increment profile 
> --------------------------------------------------------
>
>                 Key: HARMONY-5887
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5887
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Alexey Varlamov
>            Priority: Trivial
>         Attachments: inc.diff
>
>
> I've noticed "ADD counter,1" construct is used to increment dynamic profile counters. More neat and efective INC instruction should be used instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (HARMONY-5887) [drlvm][jitrino] use INC operation to increment profile

Posted by "Aleksey Shipilev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-5887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12609539#action_12609539 ] 

Aleksey Shipilev commented on HARMONY-5887:
-------------------------------------------

Alexey, this assumption is easy to make, but it's not right.

Quote from Intel IA32 Optimization Manual:
"Use of the inc and dec Instructions

The inc and dec instructions modify only a subset of the bits in the flag
register. This creates a dependence on all previous writes of the flag
register. This is especially problematic when these instructions are on
the critical path because they are used to change an address for a load on
which many other instructions depend.

Assembly/Compiler Coding Rule 42. (M impact, H generality) inc and
dec instructions should be replaced with an add or sub instruction, because
add and sub overwrite all flags, whereas inc and dec do not, therefore
creating false dependencies on earlier instructions that set the flags."

So, "ADD reg, 1" is better than "INC reg". No change is required.

> [drlvm][jitrino] use INC operation to increment profile 
> --------------------------------------------------------
>
>                 Key: HARMONY-5887
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5887
>             Project: Harmony
>          Issue Type: Improvement
>          Components: DRLVM
>            Reporter: Alexey Varlamov
>            Priority: Trivial
>
> I've noticed "ADD counter,1" construct is used to increment dynamic profile counters. More neat and efective INC instruction should be used instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.