From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/fixed-point/noassoc.c | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/fixed-point/noassoc.c (limited to 'gcc/testsuite/gcc.dg/fixed-point/noassoc.c') diff --git a/gcc/testsuite/gcc.dg/fixed-point/noassoc.c b/gcc/testsuite/gcc.dg/fixed-point/noassoc.c new file mode 100644 index 000000000..5d134e158 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fixed-point/noassoc.c @@ -0,0 +1,53 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu99 -O0" } */ + +extern void abort (void); + +/* Make sure GCC knows there is no associativity for saturating types. */ + +/* Don't transform to (temp + (0.5r + 0.8r)) */ +_Sat _Fract add_test (_Sat _Fract temp) +{ + return temp + 0.5r + 0.8r; +} + +/* Don't transform to (temp * ((-0.5r - 0.5r) * (-0.5r - 0.5r))) */ +_Sat _Fract mul_test (_Sat _Fract temp) +{ + return temp * (-0.5r - 0.5r) * (-0.5r - 0.5r); +} + +/* Don't transform to ((temp1 + temp2) * 0.5r) */ +_Sat _Fract mul_add_test (_Sat _Fract temp1, _Sat _Fract temp2) +{ + return temp1 * 0.5r + temp2 * 0.5r; +} + +/* Don't transform to ((temp1 - temp2) * 0.5r) */ +_Sat _Fract mul_sub_test (_Sat _Fract temp1, _Sat _Fract temp2) +{ + return temp1 * 0.5r - temp2 * 0.5r; +} + +int main () +{ + _Sat _Fract a; + + a = add_test (-0.5r); + if (a != 0.8r) + abort (); + + a = mul_test (0.1r); + if (a != 0.1r) + abort (); + + a = mul_add_test (0.75r, 0.5r); + if (a != 0.625r) + abort (); + + a = mul_sub_test (0.75r, -0.5r); + if (a != 0.625r) + abort (); + + return 0; +} -- cgit v1.2.3