[Bug target/81357] Extra mov for zero extend of add

qing.zhao at oracle dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 28 16:20:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81357

Qing Zhao <qing.zhao at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qing.zhao at oracle dot com

--- Comment #1 from Qing Zhao <qing.zhao at oracle dot com> ---
one question to the submitter:
   what optimization level you used to show this issue?

I tried-O0, -O1, -O2, and -O3.  I did not see this issue with -O0 and -O1.
starting to see the issue from -O2 and above. (I am using the upstream GCC on
9/27/2017).

the assembly sequence I observed with -O1 (GOOD one) is:
test1:
        add     w0, w0, 1
        uxtw    x2, w0
        adrp    x1, d
        str     x2, [x1, #:lo12:d]
        ret

the assembly sequence I observed with -O2 (BAD one) is:
test1:
        adrp    x2, d
        add     w1, w0, 1
        mov     w0, w1
        str     x1, [x2, #:lo12:d]
        ret

which shows the issue that mentioned by Andrew Pinski (i.e the "mov" insn might
be
unnecessary if the "add" insn is "add w0, w0, 1".


More information about the Gcc-bugs mailing list