[llvm-commits] CVS: llvm-test/SingleSource/UnitTests/Integer/sign.c sign.reference_output

Guoling Han han at autoesl.com
Fri Jan 26 15:35:03 PST 2007



Changes in directory llvm-test/SingleSource/UnitTests/Integer:

sign.c added (r1.1)
sign.reference_output added (r1.1)
---
Log message:

Current compiler failed to generate correct ll code


---
Diffs of the changes:  (+70 -0)

 sign.c                |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 sign.reference_output |    7 +++++
 2 files changed, 70 insertions(+)


Index: llvm-test/SingleSource/UnitTests/Integer/sign.c
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/sign.c:1.1
*** /dev/null	Fri Jan 26 17:34:57 2007
--- llvm-test/SingleSource/UnitTests/Integer/sign.c	Fri Jan 26 17:34:47 2007
***************
*** 0 ****
--- 1,63 ----
+ //===--- sign.c --- Test Cases for Bit Accurate Types --------------------===//
+ //
+ // This file was developed by Guoling Han and is distributed under the 
+ // University of Illinois Open Source License. See LICENSE.TXT for details.
+ //
+ //===----------------------------------------------------------------------===//
+ //
+ // This is a general test for arithmetic operations with signed and
+ // unsigned operands.
+ //
+ //===----------------------------------------------------------------------===//
+ 
+ #include <stdio.h>
+ 
+ typedef int __attribute__ ((bitwidth(24))) int24;
+ typedef unsigned int __attribute__ ((bitwidth(24))) uint24;
+ 
+ 
+ int
+ main ( int argc, char** argv)
+ {
+   int num, r;
+   int24 x, y, z;
+   uint24 ux, uy, uz;
+ 
+   r = rand();
+   r = r - 1804289384; // -1
+ 
+   y = r; // -1
+   uy = r; // 0xffffff
+   
+   if (argc > 1)
+     num = atoi(argv[1]);
+ 
+   
+   num = num - 0xdf5e75; //0x1000001
+ 
+   x = num;
+   ux = num;
+   printf("x = %d, ux = %u, y=%d, uy = %u\n", x, ux, y, uy);
+     
+   z = x * y;  // 0x1000001 * (-1)
+   uz = ux * uy;
+   printf("z=%d, uz=%u\n", z, uz);
+ 
+   z = x % 314;
+   uz = ux % 314;
+   printf("z=%d, uz=%u\n", z, uz);
+ 
+   z = x / 314;
+   uz = ux / 314;
+   printf("z=%d, uz=%u\n", z, uz);
+ 
+   z = (x+0xf28) / 314;
+   uz = (ux + 0xf28) / 314;
+   printf("z=%d, uz=%u\n", z, uz);
+ 
+   z = (x - 580) / 314;
+   uz = (uint24)(((uint24)(ux - (uint24)580)) / (uint24)314);
+   printf("z=%d, uz=%u\n", z, uz);
+ 
+   return 0;
+ }


Index: llvm-test/SingleSource/UnitTests/Integer/sign.reference_output
diff -c /dev/null llvm-test/SingleSource/UnitTests/Integer/sign.reference_output:1.1
*** /dev/null	Fri Jan 26 17:35:03 2007
--- llvm-test/SingleSource/UnitTests/Integer/sign.reference_output	Fri Jan 26 17:34:47 2007
***************
*** 0 ****
--- 1,7 ----
+ x = 1, ux = 1, y=-1, uy = 16777215
+ z=-1, uz=16777215
+ z=1, uz=1
+ z=0, uz=0
+ z=12, uz=12
+ z=-1, uz=53428
+ exit 0






More information about the llvm-commits mailing list