aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c
new file mode 100644
index 00000000000..1a3099a90a6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa-chrec/ssa-chrec-44.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fscalar-evolutions -fdump-tree-scev-details" } */
+
+/* That's a reduced testcase of one of my favourite simulation programs.
+ This is also known under the name: "Newton's falling apple".
+ The general version is known under the name: "the N-body simulation problem".
+
+ The physics terminology is the best to describe the scalar evolution algorithm:
+ - first determine the initial conditions of the system,
+ - then analyze its evolution.
+*/
+
+double Newton_s_apple ()
+{
+ /* Initial conditions. */
+ double g = -10.0;
+ double speed_z = 0;
+ double altitude = 3000;
+ double delta_t = 0.1;
+ double total_time = 0;
+
+ /* Laws of evolution. */
+ while (altitude > 0.0)
+ {
+ speed_z += g * delta_t;
+ altitude += speed_z * delta_t;
+ total_time += delta_t;
+ }
+
+ return total_time;
+}
+
+/*
+ speed_z -> {0.0, +, -1.0e+0}_1
+ altitude -> {3.0e+3, +, {(0.0 + -1.0e+0) * 1.00000000000000005551115123125782702118158340454e-1, +, -1.0e+0 * 1.00000000000000005551115123125782702118158340454e-1}_1}_1
+*/
+
+/* FIXME. */