Re: [PATCH] gdb/hppa-tdep.c: Fix a logical typo bug found by compiler warning

Joel Brobecker
2014-10-15T15:00:53Z

> 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