This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Vector Comparison patch
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Georg-Johann Lay <avr at gjlay dot de>
- Cc: Artem Shinkarov <artyom dot shinkaroff at gmail dot com>, Richard Guenther <richard dot guenther at gmail dot com>, Uros Bizjak <ubizjak at gmail dot com>, Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Fri, 30 Sep 2011 17:43:02 +0200
- Subject: Re: Vector Comparison patch
- References: <CAFiYyc3T7tQLzMStnusWYaRFdBA3Whu+ttsyUyKw-2ZgvDD5zw@mail.gmail.com> <CABYV9SXhUVLwya=zpHN2J75rPfvhVt0sm3J=Qo1jts9MXMVz4w@mail.gmail.com> <CAFiYyc1F1_43DXHz8_JoL15-hfT9YZmwY3+zqJv4afwQp4gQ2A@mail.gmail.com> <CAFULd4bNzYBBjPrOiy0y59=35QGon0TSKBS_+WZJbWoFGh4gTg@mail.gmail.com> <CAFiYyc16spMBjvXrcekuV9EehvjKjmpv+n9gGteqYS=ZG8i8JA@mail.gmail.com> <CAFiYyc3A4DQE5010OqMcR_f4ngr+T+4CYHoO1k1kWMzNs4zugw@mail.gmail.com> <CABYV9SWThcvUPq7ivsGnznaka6d4SZaCK9-Bgg45wLHUJf-6nA@mail.gmail.com> <4E85D9DB.3080500@gjlay.de> <CABYV9SWQ_X+5pt7ERbd3CPrCjVrKnYtcja1mQQZ0eDJNFDTywg@mail.gmail.com> <4E85E20F.7090600@gjlay.de>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Sep 30, 2011 at 05:36:47PM +0200, Georg-Johann Lay wrote:
> >> The target has
> >>
> >> 2 = sizeof (short)
> >> 2 = sizeof (int)
> >> 4 = sizeof (long int)
> >> 8 = sizeof (long long int)
> >>
> >> Could you fix that? I.e. parametrize sizeof(int) out or skip the test by means of
> >>
> >> /* { dg-require-effective-target int32plus } */
> >>
> >> or similar.
> >>
> >> Thanks, Johann
> >>
> >> [...]
> >>
> > The problem actually happens when we compare float vector with float
> > vector, it is assumed that we should get int vector as a result, but
> > it turns out that we are getting long int.
> >
> > The same with double, we assume that sizeof (double) == sizeof (long
> > long). But as it seems double has the same size as float.
>
> Yes.
>
> sizeof(double) = sizeof(float) = 4
>
> > Hm, I can put conditional of sort:
> > if (sizeof (doulbe) == sizeof (long long)) and others. Or may be there
> > is more elegant way of solving this?
>
> That's too late because this won't prevent the compiler from error.
> The error already happens at compile time, not at run time.
Isn't it possible to do something like:
vector (4, float) f0;
vector (4, float) f1;
- vector (4, int) ifres;
+ vector (4, __typeof (f0 > f1)) ifres;
f0 = (vector (4, float)){(float)argc, 1., 2., 10.};
f1 = (vector (4, float)){0., 3., 2., (float)-23};
test (4, f0, f1, ifres, "%f");
/* Double comparison. */
vector (2, double) d0;
vector (2, double) d1;
- vector (2, long long) idres;
+ vector (2, __typeof (d0 > d1)) idres;
d0 = (vector (2, double)){(double)argc, 10.};
d1 = (vector (2, double)){0., (double)-23};
test (2, d0, d1, idres, "%f");
Jakub