https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104526

--- Comment #7 from Andrew Macleod <amacleod at redhat dot com> ---
On 2/16/22 07:39, jakub at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104526
>
> --- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> +  tree type = TREE_TYPE (TREE_OPERAND (cond, 0));
> +  if (type != TREE_TYPE (TREE_OPERAND (cond, 1)))
> +    return false;
> looks unnecessarily restrictive.
> What tree-cfg.cc verification guarantees (and no need to check it in the
> ranger)
> is what verify_gimple_comparison verifies, i.e. that
>    /* For comparisons we do not have the operations type as the
>       effective type the comparison is carried out in.  Instead
>       we require that either the first operand is trivially
>       convertible into the second, or the other way around.  */
>    if (!useless_type_conversion_p (op0_type, op1_type)
>        && !useless_type_conversion_p (op1_type, op0_type))
> I think the ranger has to be prepared for non-pointer-equal type mismatches as
> long as they are useless_type_conversion_p compatible, that can happen 
> anywhere
> in the IL, including even cases like different but useless_type_conversion_p
> compatible types of binary operators like +, -, * etc.
> So I'd just remove the
>    if (type != TREE_TYPE (TREE_OPERAND (cond, 1)))
>      return false;
> lines.

The rest of ranger isn't this restrictive.. it is satisfied by 
range_compatable_p() which boils down to "same precision, same sign".

I added it here so to be super paranoid so I didn't get caught by 
something unexpected later in the routine and cause an ICE in intersect 
in the middle of building the kernel or something.  In hindsight, I 
should have used range_compatible_p...

Are you OK with the following change?  I'll bootstrap and regression test...

Andrew

Reply via email to