summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gcc.c-torture/compile/20030405-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/compile/20030405-1.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20030405-1.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/20030405-1.c b/gcc/testsuite/gcc.c-torture/compile/20030405-1.c
new file mode 100644
index 00000000000..2e61f1fa3ff
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/20030405-1.c
@@ -0,0 +1,58 @@
+/* PR optimization/10024 */
+extern int *allegro_errno;
+typedef long fixed;
+extern inline int
+fixfloor (fixed x)
+{
+ if (x >= 0)
+ return (x >> 16);
+ else
+ return ~((~x) >> 16);
+}
+extern inline int
+fixtoi (fixed x)
+{
+ return fixfloor (x) + ((x & 0x8000) >> 15);
+}
+extern inline fixed
+ftofix (double x)
+{
+ if (x > 32767.0)
+ {
+ *allegro_errno = 34;
+ return 0x7FFFFFFF;
+ }
+ if (x < -32767.0)
+ {
+ *allegro_errno = 34;
+ return -0x7FFFFFFF;
+ }
+ return (long) (x * 65536.0 + (x < 0 ? -0.5 : 0.5));
+}
+extern inline double
+fixtof (fixed x)
+{
+ return (double) x / 65536.0;
+}
+extern inline fixed
+fixdiv (fixed x, fixed y)
+{
+ if (y == 0)
+ {
+ *allegro_errno = 34;
+ return (x < 0) ? -0x7FFFFFFF : 0x7FFFFFFF;
+ }
+ else
+ return ftofix (fixtof (x) / fixtof (y));
+}
+extern inline fixed
+itofix (int x)
+{
+ return x << 16;
+}
+
+int
+foo (int n)
+{
+ return fixtoi (fixdiv (itofix (512), itofix (n)));
+}
OpenPOWER on IntegriCloud