This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/46235] inefficient bittest code generation


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46235

--- Comment #2 from Tony Poppleton <tony.poppleton at gmail dot com> 2011-01-28 16:55:48 UTC ---
Based on Richard's comment, I tried a modified version of the code replacing
the (1 << x) with just (16).

This shows that GCC (4.6 & 4.5.2) does perform an optimization similar to llvm,
and uses the testb instruction:
        movl    %edi, %eax
        movl    $1, %edx
        testb   $16, %al
        cmove   %edx, %eax
        ret

Therefore, perhaps it would be beneficial to not convert from "a & (n << x)" to
"(a >> x) & n", in the special case where the value n is 1 (or a power of 2
potentially)?

Incidentally, the above code could have been optimized further to remove the
usage of edx entirely (will make a separate PR about that)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]