qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 03/10] tcg: Swap commutative double-word compari


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 03/10] tcg: Swap commutative double-word comparisons
Date: Tue, 09 Oct 2012 08:31:47 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1

On 10/09/2012 08:16 AM, Aurelien Jarno wrote:
>> > +static bool swap_commutative2(TCGArg *p1, TCGArg *p2)
>> > +{
>> > +    int sum = 0;
>> > +    sum += temps[p1[0]].state == TCG_TEMP_CONST;
>> > +    sum += temps[p1[1]].state == TCG_TEMP_CONST;
>> > +    sum -= temps[p2[0]].state == TCG_TEMP_CONST;
>> > +    sum -= temps[p2[1]].state == TCG_TEMP_CONST;
>> > +    if (sum > 0) {
...
> Same comment are for the swap_commutative() patch, otherwise:

While I don't have an explicit test case for swap_commutative2 like
I do for swap_commutative, think about how many conditionals you'd
have to use to write this without using SUM:

  if (((temps[p1[0]].state == TCG_TEMP_CONST            // if both p1 are const
        && temps[p1[1]].state == TCG_TEMP_CONST
        && !(temps[p2[0]].state == TCG_TEMP_CONST       // ... and not both p2 
are const
             && temps[p2[1]].state == TCG_TEMP_CONST))
      || ((temps[p1[0]].state == TCG_TEMP_CONST         // if either p1 are 
const
           || temps[p1[1]].state == TCG_TEMP_CONST)
          && !temps[p2[0]].state == TCG_TEMP_CONST      // ... and neither p2 
are const
          && !temps[p2[1]].state == TCG_TEMP_CONST))

I don't see how that can possibly be easier to understand.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]