summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/vrp13.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/tree-ssa/vrp13.c
downloadcbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.bz2
cbb-gcc-4.6.4-15d2061ac0796199866debe9ac87130894b0cdd3.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa/vrp13.c')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp13.c258
1 files changed, 258 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp13.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp13.c
new file mode 100644
index 000000000..4b3afdbc8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp13.c
@@ -0,0 +1,258 @@
+/* { dg-do run } */
+/* { dg-options -O2 } */
+
+extern void abort (void);
+
+foo_div (int i, int j)
+{
+ int k;
+
+ /* [-INF, -1] / [1, +INF] should not give [-1, -1]. */
+ if (i <= -1)
+ if (j >= 1)
+ {
+ k = i / j;
+ if (k == -1)
+ abort ();
+
+ return k;
+ }
+
+ /* [-20, -10] / [2, 10] should give [-10, -1]. */
+ if (i >= -20)
+ if (i <= -10)
+ if (j >= 2)
+ if (j <= 10)
+ {
+ k = i / j;
+ if (k < -10)
+ link_error ();
+ if (k > -1)
+ link_error ();
+
+ return k;
+ }
+
+ /* [-20, -10] / [-10, -2] should give [1, 10]. */
+ if (i >= -20)
+ if (i <= -10)
+ if (j >= -10)
+ if (j <= -2)
+ {
+ k = i / j;
+ if (k < 1)
+ link_error ();
+ if (k > 10)
+ link_error ();
+
+ return k;
+ }
+
+ /* [-20, 10] / [2, 10] should give [-10, 5]. */
+ if (i >= -20)
+ if (i <= 10)
+ if (j >= 2)
+ if (j <= 10)
+ {
+ k = i / j;
+ if (k < -10)
+ link_error ();
+ if (k > 5)
+ link_error ();
+
+ return k;
+ }
+
+ /* [-20, 10] / [-10, -2] should give [-5, 10]. */
+ if (i >= -20)
+ if (i <= 10)
+ if (j >= -10)
+ if (j <= -2)
+ {
+ k = i / j;
+ if (k < -5)
+ link_error ();
+ if (k > 10)
+ link_error ();
+
+ return k;
+ }
+
+ /* [10, 20] / [2, 10] should give [1, 10]. */
+ if (i >= 10)
+ if (i <= 20)
+ if (j >= 2)
+ if (j <= 10)
+ {
+ k = i / j;
+ if (k < 1)
+ link_error ();
+ if (k > 10)
+ link_error ();
+
+ return k;
+ }
+
+ /* [10, 20] / [-10, -2] should give [-10, -1]. */
+ if (i >= 10)
+ if (i <= 20)
+ if (j >= -10)
+ if (j <= -2)
+ {
+ k = i / j;
+ if (k > -1)
+ link_error ();
+ if (k < -10)
+ link_error ();
+
+ return k;
+ }
+
+ abort ();
+}
+
+
+foo_mult (int i, int j)
+{
+ int k;
+
+ /* [-20, -10] * [2, 10] should give [-200, -20]. */
+ if (i >= -20)
+ if (i <= -10)
+ if (j >= 2)
+ if (j <= 10)
+ {
+ k = i * j;
+ if (k < -200)
+ link_error ();
+ if (k > -20)
+ link_error ();
+
+ return k;
+ }
+
+ /* [-20, -10] * [-10, -2] should give [20, 200]. */
+ if (i >= -20)
+ if (i <= -10)
+ if (j >= -10)
+ if (j <= -2)
+ {
+ k = i * j;
+ if (k < 20)
+ link_error ();
+ if (k > 200)
+ link_error ();
+
+ return k;
+ }
+
+ /* [-20, 10] * [2, 10] should give [-200, 100]. */
+ if (i >= -20)
+ if (i <= 10)
+ if (j >= 2)
+ if (j <= 10)
+ {
+ k = i * j;
+ if (k < -200)
+ link_error ();
+ if (k > 100)
+ link_error ();
+
+ return k;
+ }
+
+ /* [-20, 10] * [-10, -2] should give [-100, 200]. */
+ if (i >= -20)
+ if (i <= 10)
+ if (j >= -10)
+ if (j <= -2)
+ {
+ k = i * j;
+ if (k < -100)
+ link_error ();
+ if (k > 200)
+ link_error ();
+
+ return k;
+ }
+
+ /* [10, 20] * [2, 10] should give [20, 200]. */
+ if (i >= 10)
+ if (i <= 20)
+ if (j >= 2)
+ if (j <= 10)
+ {
+ k = i * j;
+ if (k < 20)
+ link_error ();
+ if (k > 200)
+ link_error ();
+
+ return k;
+ }
+
+ /* [10, 20] * [-10, -2] should give [-200, -20]. */
+ if (i >= 10)
+ if (i <= 20)
+ if (j >= -10)
+ if (j <= -2)
+ {
+ k = i * j;
+ if (k < -200)
+ link_error ();
+ if (k > -20)
+ link_error ();
+
+ return k;
+ }
+
+ abort ();
+}
+
+
+main()
+{
+ if (foo_div (-10, 5) != -2)
+ abort ();
+
+ if (foo_div (-16, 4) != -4)
+ abort ();
+
+ if (foo_div (-15, -5) != 3)
+ abort ();
+
+ if (foo_div (8, 2) != 4)
+ abort ();
+
+ if (foo_div (10, -2) != -5)
+ abort ();
+
+ if (foo_div (20, 5) != 4)
+ abort ();
+
+ if (foo_div (15, -3) != -5)
+ abort ();
+
+ if (foo_mult (-10, 5) != -50)
+ abort ();
+
+ if (foo_mult (-16, 4) != -64)
+ abort ();
+
+ if (foo_mult (-15, -5) != 75)
+ abort ();
+
+ if (foo_mult (8, 2) != 16)
+ abort ();
+
+ if (foo_mult (10, -2) != -20)
+ abort ();
+
+ if (foo_mult (20, 5) != 100)
+ abort ();
+
+ if (foo_mult (15, -3) != -45)
+ abort ();
+
+ return 0;
+}