This is the mail archive of the mailing list for the GCC 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: broken arithmetic operations on vectors (c and c++)

Aldy Hernandez wrote:
Why not just the moral equivalent of:

same_type_p (langhooks.signed_type(t1), langhooks.signed_type(t2))

Oooo. Nice.

Ok, I used the equality operator, since that's how it seems we compare
types throughout the FEs.

Here is an updated patch which I'm testing.  It's for the C and C++
front ends.  C was borked as well.

In testing I noticed gcc.dg/simd-1b.c had most of the tests
XFAILed.  They now work.  I've re-enabled them.

How does this look?

I'm concerned about the pointer-equality test, but, because c_common_signed_type grabs the TYPE_MAIN_VARIANT, it should work for scalars, as RTH says. I think that to make this a bit more bulletproof, you should (a) add a comment noting that c_common_signed_type does that, and (b) assert that the inputs are INTEGER_TYPE or REAL_TYPE. Perhaps even change the name of the function to same_scalar_type_ignoring_signedness.

The point of all that is that "signed_type (array_type1) == signed_type (array_type2)" might not be true, even if the array types are the same, and that the C signed type hooks will accept such input, even though its weird. So, an assertion to make clear that your function won't accept these would be nice.

The C++ change is OK.

Mark Mitchell
CodeSourcery, LLC
(916) 791-8304

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