This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Tighten checking of vector comparisons
On Thu, Nov 22, 2012 at 11:59 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
> (I forgot to send this at the time)
>
>
> On Sun, 4 Nov 2012, Richard Biener wrote:
>
>>> - else if (!INTEGRAL_TYPE_P (type) && TREE_CODE (type) !=
>>> VECTOR_TYPE)
>>> + else if (!INTEGRAL_TYPE_P (type) && !VOID_TYPE_P (type)
>>> + && TREE_CODE (type) != VECTOR_TYPE)
>
> [...]
>>
>> Ok for this part.
>
>
> Applied, thanks.
>
>
>>> Index: gcc/tree-cfg.c
>>> ===================================================================
>>> --- gcc/tree-cfg.c (revision 193060)
>>> +++ gcc/tree-cfg.c (working copy)
>>> @@ -3263,21 +3263,30 @@ verify_gimple_comparison (tree type, tre
>>> error ("mismatching comparison operand types");
>>> debug_generic_expr (op0_type);
>>> debug_generic_expr (op1_type);
>>> return true;
>>> }
>>>
>>> /* The resulting type of a comparison may be an effective boolean
>>> type.
>>> */
>>> if (INTEGRAL_TYPE_P (type)
>>> && (TREE_CODE (type) == BOOLEAN_TYPE
>>> || TYPE_PRECISION (type) == 1))
>>> - ;
>>> + {
>>> + if (TREE_CODE (op0_type) == VECTOR_TYPE
>>> + || TREE_CODE (op1_type) == VECTOR_TYPE)
>>> + {
>>> + error ("vector comparison returning a boolean");
>>> + debug_generic_expr (op0_type);
>>> + debug_generic_expr (op1_type);
>>> + return true;
>>> + }
>>
>>
>> verify_gimple_* should have "positive" checks, thus, check that
>> if there are vector operands the comparison result should be a
>> vector. Not complaining about a vector comparison having a
>> boolean result.
>
>
> I wasn't sure what that was supposed to look like, so I dropped it for now.
Ok, looking closer we have
/* The resulting type of a comparison may be an effective boolean type. */
if (INTEGRAL_TYPE_P (type)
&& (TREE_CODE (type) == BOOLEAN_TYPE
|| TYPE_PRECISION (type) == 1))
;
/* Or an integer vector type with the same size and element count
as the comparison operand types. */
else if (TREE_CODE (type) == VECTOR_TYPE
&& TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
{
...
Thus you are rejecting a boolean valued vector comparison which we
otherwise happily accept. I suppose that makes sense (even though
at least equality compares can make sense).
Thus that hunk is ok as well.
Thanks,
Richard.
> --
> Marc Glisse