[PATCHv3, resent] Add a warning for suspicious use of conditional expressions in boolean context

Richard Earnshaw (lists) Richard.Earnshaw@arm.com
Wed Sep 21 14:46:00 GMT 2016


On 20/09/16 16:30, Bernd Schmidt wrote:
> On 09/20/2016 05:18 PM, Jeff Law wrote:
>>> I assume HARD_FRAME_POINTER_REGNUM is never zero.
>> It could be zero.  It's just a hard register number.  No target has the
>> property that its hard frame pointer register is 0 though :-)
> 
> git blame to the rescue. The current state comes from one of tbsaunde's
> cleanup patches:
> 
>> diff --git a/gcc/regrename.c b/gcc/regrename.c
> index 174d3b5..e5248a5 100644
> --- a/gcc/regrename.c
> +++ b/gcc/regrename.c
> @@ -442,12 +442,10 @@ rename_chains (void)
>         continue;
> 
>        if (fixed_regs[reg] || global_regs[reg]
> -#if !HARD_FRAME_POINTER_IS_FRAME_POINTER
> -         || (frame_pointer_needed && reg == HARD_FRAME_POINTER_REGNUM)
> -#else
> -         || (frame_pointer_needed && reg == FRAME_POINTER_REGNUM)
> -#endif
> -         )
> +         || (!HARD_FRAME_POINTER_IS_FRAME_POINTER && frame_pointer_needed
> +             && reg == HARD_FRAME_POINTER_REGNUM)
> +         || (HARD_FRAME_POINTER_REGNUM && frame_pointer_needed

Surely, based on the logic of the previous ifdefs, this line should read
 +         || (HARD_FRAME_POINTER_IS_FRAME_POINTER && frame_pointer_needed

R.



More information about the Gcc-patches mailing list