This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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: [PATCH] gdb/hppa-tdep.c: Fix a logical typo bug found by compiler warning


> On 10/15/2014 05:29 AM, Andreas Schwab wrote:
> > Chen Gang <gang.chen.5i5j@gmail.com> writes:
> > 
> >>  	  && (((inst >> 6) & 0xf) == 0x8
> >> -	      || (inst >> 6) & 0xf) == 0x9))
> >> +	      || ((inst >> 6) & 0xf) == 0x9)))
> > 
> >              ((inst >> 6) & 0xe) == 8
> > 
> > Andreas.
> > 
> 
> I guess, your fixing may like below, which will be a different logical
> working flow.

I think Andreas is telling you that...

     ((inst >> 6) & 0xf) == 0x8
     || ((inst >> 6) & 0xf) == 0x9

... is logically equivalent to ...

     ((inst >> 6) & 0xe) == 8

In other word, if it does not matter if bit 7 is set or not
(the difference between 0x8 and 0x9) all you have to do is mask it.
That way, you test both conditions with one comparison instead of 2.

-- 
Joel


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