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

--- Comment #3 from Jiajing_Zheng <jiajing_zheng at 163 dot com> ---
(In reply to Jakub Jelinek from comment #1)
> This is because already the FE optimizes it, when it sees that
> ((int)(g_B * g_A[1])) & (g_A[1] & g_A[0]) | g_A[0]
> is just being added to unsigned char element, the upper bits of it aren't
> needed, so the multiplication and & and | are all performed in unsigned char
> rather than wider types.

Thanks for your reply. I then used 'gcc -O2 mutation.c -fsanitize=undefined -S'
to generate mutation.s. As shown below, the relevant compilation sections 'addl
%r13d, %r13d' show that the statement 'g_A[0] += temp & (g_A[1] & g_A[0]) |
g_A[0];' in the loop is optimized to 'g_A[0] += g_A[0];'.

  .L8:
        addl    %r13d, %r13d
        movslq  %ebx, %rsi
        movb    %r13b, g_A(%rip)
        cmpq    $4, %rsi
        jnb     .L12

Is that what you mean by "the FE optimizes it"? I want to see the file
generated by a file.c after FE optimization, should I go to the corresponding
assembly file.s?

Reply via email to