incorrect code generation with -O2 option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
GCC code generator generates wrong code with -O2 optimization option for simple statement like " x = -x;" where x is double type.

==Assembly code
 # x = -x
        movw    r2, r0         # move r2 to r0
        movw    r3, r1         # move r3 to r1
        addw    $-32768, r1    # add 0x8000 to r1 ie negate
===
Note r0-r3 are 16 bit registers and above code is valid. But same code is generated with 32 bit source register as:

==Assembly code
 # x = -x
        movw    r13, r0         # move r13_L to r0
        movw    r13, r1         # move r13_L to r1
        addw    $-32768, r1    # add 0x8000 to r1 ie negate
===

In the above generated code, r13 higher bit never changed, which is not correct.
Expected code could be:

==Assembly code
 # x = -x
        movd    r13, (r1,r0)          # move r13 to r1-r0
        addd    $0x80000000, (r1-r0)  # add 0x80000000 to r1 ie negate
===

Could please advise, if this issue could be fixed in gcc core or target port?
If its gcc core I will file PR on this.

Thank you very much for your suggestion.

PS: The above issues with cr16-elf target and its port submission is in review (ie 3 reviews completed and review-4 pending).

Thanks
Swami


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux