This is the mail archive of the gcc-patches@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]

Re: [Ada] Avoid doing arithmetics in ENUMERAL_TYPE


On Thu, Apr 23, 2009 at 1:36 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Uh, ok. ?This isn't on purpose (well, on my purpose).
>
> I think this could pessimize for BOOLEAN_TYPEs.

Hmm.  With C/C++ semantics (true + true == true) we should
be able to lower boolean arithmetic to bit operations not requiring
truncation.  (In C/C++ bool + bool is (int)bool + (int)bool != 0).

For

bool foo(bool a, bool b)
{
 return a + b;
}

we currently generate

        movzbl  %dil, %edi
        movzbl  %sil, %esi
        addl    %edi, %esi
        setne   %al

while for return a | b we do

        movl    %edi, %eax
        orb     %sil, %al
        setne   %al

both cases should not be affected by truncation to 1 bit precision.

Richard.


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