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.misc-tests/sort2.c | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.misc-tests/sort2.c (limited to 'gcc/testsuite/gcc.misc-tests/sort2.c') diff --git a/gcc/testsuite/gcc.misc-tests/sort2.c b/gcc/testsuite/gcc.misc-tests/sort2.c new file mode 100644 index 000000000..06b150b93 --- /dev/null +++ b/gcc/testsuite/gcc.misc-tests/sort2.c @@ -0,0 +1,54 @@ +/* Simple test program: bubble sort of a fixed table. */ +/* This demonstrates some of the compiler's common-subexpression*/ +/* elimination capabilities. For example, inspect the code */ +/* generated for procedure Sort_array. See the Programmer's */ +/* Guide for how to request an assembly listing on your host. */ + +typedef unsigned char boolean; + +void Sort_array(); +int Tab[100]; + +main () { + int I,J,K,L; + +for (L = 0; L < 1000; L++) { + /* Initialize the table that will be sorted. */ + K = 0; + for (I = 9; I >= 0; I--) + for (J = I*10; J < (I+1)*10; J++) + Tab[K++] = J&1 ? J+1 : J-1; + +/* Print_array(); */ + Sort_array(Tab,99); /* Sort it. */ +/* Print_array(); */ +} + return 0; +} + +void Sort_array(Tab,Last) int Tab[]; int Last; { + boolean Swap; + int Temp,I; + do { + Swap = 0; + for (I = 0; I Tab[I+1]) { + Temp = Tab[I]; + Tab[I] = Tab[I+1]; + Tab[I+1] = Temp; + Swap = 1; + } + } + while (Swap); +} + + +void Print_array() { + int I,J; + /*printf("\nArray Contents:\n");*/ + for (I=0; I<=9; I++) { + /*printf("%5d:",10*I); */ + for (J=0; J<=9; J++); /*printf("%5d",Tab[10*I+J]); */ + /* printf("\n");*/ + } +} -- cgit v1.2.3