Message ID | CABYV9SUkK4TNLpJG3FXcXRHMtPTgH4Sbr9LW-a=p7cQz5i+qRA@mail.gmail.com |
---|---|
State | New |
Headers | show |
Artem Shinkarov schrieb: > On Fri, Sep 30, 2011 at 4:54 PM, Jakub Jelinek <jakub@redhat.com> wrote: > >>On Fri, Sep 30, 2011 at 04:48:41PM +0100, Artem Shinkarov wrote: >> >>>Most likely we can. The question is what do we really want to check >>>with this test. My intention was to check that a programmer can >>>statically get correspondence of the types, in a sense that sizeof >>>(float) == sizeof (int) and sizeof (double) == sizeof (long long). As >>>it seems my original assumption does not hold. Before using __typeof, >>>I would try to make sure that there is no other way to determine these >>>correspondences. >> >>You can use preprocessor too, either just surround the whole test >>with #if __SIZEOF_INT__ == __SIZEOF_FLOAT__ and similar, >>or select the right type through preprocessor >>#if __SIZEOF_INT__ == __SIZEOF_FLOAT__ >>#define FLOATCMPTYPE int >>#elif __SIZEOF_LONG__ == __SIZEOF_FLOAT__ >>#define FLOATCMPTYPE long >>#else >>... >>or __typeof, etc. >> >> Jakub > > Ok, here is a patch which uses __typeof. Passes on x86_64. Thanks, I will test on avr next week. Johann > > Artem. >
Artem Shinkarov schrieb: > On Fri, Sep 30, 2011 at 4:54 PM, Jakub Jelinek <jakub@redhat.com> wrote: >> On Fri, Sep 30, 2011 at 04:48:41PM +0100, Artem Shinkarov wrote: >>> Most likely we can. The question is what do we really want to check >>> with this test. My intention was to check that a programmer can >>> statically get correspondence of the types, in a sense that sizeof >>> (float) == sizeof (int) and sizeof (double) == sizeof (long long). As >>> it seems my original assumption does not hold. Before using __typeof, >>> I would try to make sure that there is no other way to determine these >>> correspondences. >> You can use preprocessor too, either just surround the whole test >> with #if __SIZEOF_INT__ == __SIZEOF_FLOAT__ and similar, >> or select the right type through preprocessor >> #if __SIZEOF_INT__ == __SIZEOF_FLOAT__ >> #define FLOATCMPTYPE int >> #elif __SIZEOF_LONG__ == __SIZEOF_FLOAT__ >> #define FLOATCMPTYPE long >> #else >> ... >> or __typeof, etc. >> >> Jakub >> > > Ok, here is a patch which uses __typeof. Passes on x86_64. > > Artem. The patch from http://gcc.gnu.org/ml/gcc-patches/2011-09/msg02060.html http://gcc.gnu.org/ml/gcc-patches/2011-09/txt00337.txt works for me. If it's ok from maintainer I can apply it for you. Johann
On Tue, Oct 04, 2011 at 11:32:37AM +0200, Georg-Johann Lay wrote: > The patch from > http://gcc.gnu.org/ml/gcc-patches/2011-09/msg02060.html > http://gcc.gnu.org/ml/gcc-patches/2011-09/txt00337.txt > works for me. > > If it's ok from maintainer I can apply it for you. It is fine with a suitable ChangeLog entry. Jakub
Jakub Jelinek schrieb: > On Tue, Oct 04, 2011 at 11:32:37AM +0200, Georg-Johann Lay wrote: >> The patch from >> http://gcc.gnu.org/ml/gcc-patches/2011-09/msg02060.html >> http://gcc.gnu.org/ml/gcc-patches/2011-09/txt00337.txt >> works for me. >> >> If it's ok from maintainer I can apply it for you. > > It is fine with a suitable ChangeLog entry. > > Jakub It's here: http://gcc.gnu.org/viewcvs?view=revision&revision=179497 Johann
Index: gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c =================================================================== --- gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c (revision 179378) +++ gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c (working copy) @@ -39,17 +39,17 @@ int main (int argc, char *argv[]) { int i; i0 = (vector (4, INT)){argc, 1, 2, 10}; - i1 = (vector (4, INT)){0, 3, 2, (INT)-23}; + i1 = (vector (4, INT)){0, 3, 2, (INT)-23}; test (4, i0, i1, ires, "%i"); #undef INT -#define INT unsigned int +#define INT unsigned int vector (4, int) ures; vector (4, INT) u0; vector (4, INT) u1; u0 = (vector (4, INT)){argc, 1, 2, 10}; - u1 = (vector (4, INT)){0, 3, 2, (INT)-23}; + u1 = (vector (4, INT)){0, 3, 2, (INT)-23}; test (4, u0, u1, ures, "%u"); #undef INT @@ -60,7 +60,7 @@ int main (int argc, char *argv[]) { vector (8, short) sres; s0 = (vector (8, SHORT)){argc, 1, 2, 10, 6, 87, (SHORT)-5, 2}; - s1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0}; + s1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0}; test (8, s0, s1, sres, "%i"); #undef SHORT @@ -70,7 +70,7 @@ int main (int argc, char *argv[]) { vector (8, short) usres; us0 = (vector (8, SHORT)){argc, 1, 2, 10, 6, 87, (SHORT)-5, 2}; - us1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0}; + us1 = (vector (8, SHORT)){0, 3, 2, (SHORT)-23, 12, 10, (SHORT)-2, 0}; test (8, us0, us1, usres, "%u"); #undef SHORT @@ -102,19 +102,19 @@ int main (int argc, char *argv[]) { /* Float comparison. */ vector (4, float) f0; vector (4, float) f1; - vector (4, int) ifres; + __typeof (f0 == f1) ifres; f0 = (vector (4, float)){(float)argc, 1., 2., 10.}; - f1 = (vector (4, float)){0., 3., 2., (float)-23}; + 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; + __typeof (d0 == d1) idres; d0 = (vector (2, double)){(double)argc, 10.}; - d1 = (vector (2, double)){0., (double)-23}; + d1 = (vector (2, double)){0., (double)-23}; test (2, d0, d1, idres, "%f");