summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/addadd.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/assoc-1.c31
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c19
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c13
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-19.c62
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c37
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c13
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-12.c3
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-13.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-14.c5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-26.c36
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-4.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ldist-6.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/mulcmp-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c38
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81346-1.c37
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81346-2.c37
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81346-3.c109
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81346-4.c79
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81346-5.c17
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81369.c23
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81388-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81388-2.c14
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr81396.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-1.c62
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-10.c44
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-11.c51
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-2.c62
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-3.c108
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-4.c61
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-5.c63
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-6.c65
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-7.c63
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-8.c60
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-9.c90
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/slsr-35.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/slsr-36.c2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/slsr-4.c8
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-30.c4
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp116.c12
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vrp24.c10
42 files changed, 1371 insertions, 44 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/addadd.c b/gcc/testsuite/gcc.dg/tree-ssa/addadd.c
index 16474db6565..454ec2a570d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/addadd.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/addadd.c
@@ -23,11 +23,6 @@ int i(int x){
x += __INT_MAX__;
return x;
}
-typedef int S __attribute__((vector_size(16)));
-void j(S*x){
- *x += __INT_MAX__;
- *x += __INT_MAX__;
-}
/* { dg-final { scan-tree-dump-times " \\+ 24;" 2 "optimized" } } */
/* { dg-final { scan-tree-dump-times "\\(unsigned int\\)" 2 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/assoc-1.c b/gcc/testsuite/gcc.dg/tree-ssa/assoc-1.c
new file mode 100644
index 00000000000..f9821910bd0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/assoc-1.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized-raw -fno-tree-reassoc" } */
+
+int f0(int a,int b,int c){
+ int d = a + b;
+ int e = c + b;
+ return d - e;
+}
+int f1(int a,int b,int c){
+ int d = a + b;
+ int e = b - c;
+ return d - e;
+}
+int f2(int a,int b,int c){
+ int d = a + b;
+ int e = c - b;
+ return e + d;
+}
+int f3(int a,int b,int c){
+ int d = a - b;
+ int e = c - b;
+ return d - e;
+}
+int f4(int a,int b,int c){
+ int d = b - a;
+ int e = c - b;
+ return e + d;
+}
+
+/* { dg-final { scan-tree-dump-times "plus_expr" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "minus_expr" 3 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c b/gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c
new file mode 100644
index 00000000000..cc0e9d429b4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/assoc-2.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-gimple-raw -fdump-tree-optimized-raw" } */
+
+int f0(int a, int b){
+ return a * 33 * b * 55;
+}
+
+int f1(int a){
+ a *= 33;
+ return a * 55;
+}
+
+int f2(int a, int b){
+ a *= 33;
+ return a * b * 55;
+}
+
+/* { dg-final { scan-tree-dump-times "mult_expr" 7 "gimple" } } */
+/* { dg-final { scan-tree-dump-times "mult_expr" 5 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c
index 184dd10ddae..17526113d4b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/attr-hotcold-2.c
@@ -1,8 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-profile_estimate-blocks-details" } */
+/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
-void g(void);
-void h(void);
+int v1, v2;
void f(int x, int y)
{
if (x) goto A;
@@ -10,19 +9,19 @@ void f(int x, int y)
return;
A: __attribute__((cold))
- g();
+ v1 = x;
return;
B: __attribute__((hot))
- h();
+ v2 = y;
return;
}
/* { dg-final { scan-tree-dump-times "hot label heuristics" 1 "profile_estimate" } } */
/* { dg-final { scan-tree-dump-times "cold label heuristics" 1 "profile_estimate" } } */
-/* { dg-final { scan-tree-dump "A \\\[0\\\..*\\\]" "profile_estimate" } } */
+/* { dg-final { scan-tree-dump-times "combined heuristics: 0\\\..*" 1 "profile_estimate" } } */
/* Note: we're attempting to match some number > 6000, i.e. > 60%.
The exact number ought to be tweekable without having to juggle
the testcase around too much. */
-/* { dg-final { scan-tree-dump "B \\\[\[6-9\]\[0-9\]\\\..*\\\]" "profile_estimate" } } */
+/* { dg-final { scan-tree-dump-times "combined heuristics: \[6-9\]\[0-9\]\\\..*" 1 "profile_estimate" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-19.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-19.c
new file mode 100644
index 00000000000..e0439384dd7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-19.c
@@ -0,0 +1,62 @@
+/* PR tree-optimization/80397 - missing -Wformat-overflow with arguments
+ of enum types
+ { dg-do compile }
+ { dg-options "-O2 -Wall -Wformat-overflow=1 -ftrack-macro-expansion=0" }
+ { dg-require-effective-target int32plus } */
+
+void sink (char*);
+
+long long integer_range (long long min, long long max)
+{
+ extern long long integer_value (void);
+ long long n = integer_value ();
+ return n < min || max < n ? min : n;
+}
+
+typedef enum { i0, imax = __INT_MAX__ } Int;
+typedef enum { ll0, llmax = __LONG_LONG_MAX__ } LLong;
+
+#define R(T, min, max) (T)integer_range (min, max)
+
+char buffer[1];
+#define T(fmt, ...) \
+ __builtin_sprintf (buffer + 1, fmt, __VA_ARGS__), sink (buffer)
+
+void test_bool (_Bool b)
+{
+ T ("%hhi", b); // { dg-warning "writing 1 byte" }
+ T ( "%hi", b); // { dg-warning "writing 1 byte" }
+ T ( "%i", b); // { dg-warning "writing 1 byte" }
+}
+
+void test_enum (void)
+{
+ T ("%hhi", R (Int, 1, 1)); // { dg-warning "writing 1 byte" }
+ T ("%hhi", R (Int, 1, 22)); // { dg-warning "between 1 and 2 bytes" }
+
+ T ( "%hi", R (Int, 1, 2)); // { dg-warning "writing 1 " }
+ T ( "%hi", R (Int, 1, 22)); // { dg-warning "between 1 and 2 " }
+ T ( "%hi", R (Int, 22, 333)); // { dg-warning "between 2 and 3 " }
+ T ( "%hi", R (Int, 333, 4444)); // { dg-warning "between 3 and 4 " }
+
+ T ( "%i", R (Int, 1, 1)); // { dg-warning "writing 1 " }
+ T ( "%i", R (Int, 1, 22)); // { dg-warning "between 1 and 2 " }
+ T ( "%i", R (Int, 22, 333)); // { dg-warning "between 2 and 3 " }
+ T ( "%i", R (Int, 333, 4444)); // { dg-warning "between 3 and 4 " }
+ T ( "%i", R (Int, 4444, 55555)); // { dg-warning "between 4 and 5 " }
+
+#if __LONG_MAX__ == __LONG_LONG_MAX__
+# define LLI "%li"
+#else
+# define LLI "%lli"
+#endif
+
+ T (LLI, R (LLong, 1, 1)); // { dg-warning "writing 1 " }
+ T (LLI, R (LLong, 1, 22)); // { dg-warning "between 1 and 2 " }
+ T (LLI, R (LLong, 22, 333)); // { dg-warning "between 2 and 3 " }
+ T (LLI, R (LLong, 333, 4444)); // { dg-warning "between 3 and 4 " }
+ T (LLI, R (LLong, 4444, 55555)); // { dg-warning "between 4 and 5 " }
+
+ T (LLI, R (LLong, 4444, 1234567890)); // { dg-warning "between 4 and 10 " }
+ T (LLI, R (LLong, 4444, 12345678901)); // { dg-warning "between 4 and 11 " }
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c
new file mode 100644
index 00000000000..de3e7b242ce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-1.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target c99_runtime } */
+/* { dg-options "-O2 -ffast-math -fdump-tree-gimple" } */
+/* { dg-add-options c99_runtime } */
+float f(float x)
+{
+ return (x > 0.f ? -1.f : 1.f);
+}
+float f1(float x)
+{
+ return (x > 0.f ? 1.f : -1.f);
+}
+float g(float x)
+{
+ return (x >= 0.f ? -1.f : 1.f);
+}
+float g1(float x)
+{
+ return (x >= 0.f ? 1.f : -1.f);
+}
+float h(float x)
+{
+ return (x < 0.f ? -1.f : 1.f);
+}
+float h1(float x)
+{
+ return (x < 0.f ? 1.f : -1.f);
+}
+float i(float x)
+{
+ return (x <= 0.f ? -1.f : 1.f);
+}
+float i1(float x)
+{
+ return (x <= 0.f ? 1.f : -1.f);
+}
+/* { dg-final { scan-tree-dump-times "copysign" 8 "gimple"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c
new file mode 100644
index 00000000000..de52c5f7c80
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-sign-2.c
@@ -0,0 +1,13 @@
+/* { dg-options "-O2 -ffast-math -fdump-tree-optimized" } */
+/* { dg-do compile } */
+float f(float x)
+{
+ float t = __builtin_copysignf (1.0f, x);
+ return x * t;
+}
+float f1(float x)
+{
+ float t = __builtin_copysignf (1.0f, -x);
+ return x * t;
+}
+/* { dg-final { scan-tree-dump-times "ABS" 2 "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-12.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-12.c
index 53551cabd1e..625dd92128e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-12.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-12.c
@@ -18,4 +18,5 @@ int foo (int * __restrict__ ia,
return oya[22] + oyb[21];
}
-/* { dg-final { scan-tree-dump-times "distributed: split to 2 loops" 1 "ldist" } } */
+/* Distributing the loop doesn't expose more parallelism. */
+/* { dg-final { scan-tree-dump-times "distributed: split to 2 loops" 0 "ldist" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-13.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-13.c
index ba39d4dfce7..8c9fd567e1e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-13.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-13.c
@@ -16,6 +16,5 @@ float foo (int n)
return tmp;
}
-/* We should apply loop distribution. */
-
-/* { dg-final { scan-tree-dump "Loop 1 distributed: split to 2 loops" "ldist" } } */
+/* Distributing the loop doesn't expose more parallelism. */
+/* { dg-final { scan-tree-dump-not "Loop 1 distributed: split to 2 loops" "ldist" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-14.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-14.c
index 48c1040f4b3..fa4d1a82879 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-14.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-14.c
@@ -21,6 +21,5 @@ float foo (int n)
return tmp;
}
-/* We should apply loop distribution. */
-
-/* { dg-final { scan-tree-dump "Loop 1 distributed: split to 2 loops" "ldist" } } */
+/* Distributing the loop doesn't expose more parallelism. */
+/* { dg-final { scan-tree-dump-not "Loop 1 distributed: split to 2 loops" "ldist" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-26.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-26.c
new file mode 100644
index 00000000000..3a698846c89
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-26.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -ftree-loop-distribution -fdump-tree-ldist-details" } */
+
+extern void abort (void);
+
+int a[130], b[128], c[128];
+
+int __attribute__((noinline,noclone))
+foo (int len, int x)
+{
+ int i;
+ for (i = 1; i <= len; ++i)
+ {
+ a[i] = a[i + 2] + 1;
+ b[i] = 0;
+ a[i + 1] = a[i] - 3;
+ if (i < x)
+ c[i] = a[i];
+ }
+ return i;
+}
+
+int main()
+{
+ int i;
+ for (i = 0; i < 130; ++i)
+ a[i] = i;
+ foo (127, 67);
+ if (a[0] != 0 || a[1] != 4 || a[127] != 130)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "distributed: split to 2 loops and 0 library calls" "ldist" } } */
+/* { dg-final { scan-tree-dump "distributed: split to 1 loops and 1 library calls" "ldist" } } */
+/* { dg-final { scan-tree-dump "generated memset zero" "ldist" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-4.c
index c36daf0714b..4def9b4719d 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-4.c
@@ -20,7 +20,5 @@ int loop1 (int k)
return b[100-1][1];
}
-/* The current cost model fuses the two partitions because they have
- similar memory accesses. */
-/* { dg-final { scan-tree-dump "similar memory accesses" "ldist" } } */
+/* Distributing inner loop doesn't expose more parallelism. */
/* { dg-final { scan-tree-dump-times "distributed: split to 2 loops" 0 "ldist" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-6.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-6.c
index 8eb1c628837..e0a68d87f7f 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-6.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-6.c
@@ -34,4 +34,4 @@ int loop1 (int k)
return a[1000-2] + b[1000-1] + c[1000-2] + d[1000-2];
}
-/* { dg-final { scan-tree-dump-times "distributed: split to 2 loops" 0 "ldist" } } */
+/* { dg-final { scan-tree-dump-times "distributed: split to 2 loops" 0 "ldist" { xfail *-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/mulcmp-1.c b/gcc/testsuite/gcc.dg/tree-ssa/mulcmp-1.c
new file mode 100644
index 00000000000..6ff2ff5a388
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/mulcmp-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized-raw" } */
+
+int f(unsigned a,unsigned b){
+ a *= 3;
+ b *= 3;
+ return a == b;
+}
+
+/* { dg-final { scan-tree-dump-not "mult_expr" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c
new file mode 100644
index 00000000000..d74ba2fe630
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/mult-abs-2.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target c99_runtime } */
+/* { dg-options "-O2 -ffast-math -fdump-tree-gimple" } */
+/* { dg-add-options c99_runtime } */
+
+float f(float x)
+{
+ return x * (x > 0.f ? -1.f : 1.f);
+}
+float f1(float x)
+{
+ return x * (x > 0.f ? 1.f : -1.f);
+}
+float g(float x)
+{
+ return x * (x >= 0.f ? -1.f : 1.f);
+}
+float g1(float x)
+{
+ return x * (x >= 0.f ? 1.f : -1.f);
+}
+float h(float x)
+{
+ return x * (x < 0.f ? -1.f : 1.f);
+}
+float h1(float x)
+{
+ return x * (x < 0.f ? 1.f : -1.f);
+}
+float i(float x)
+{
+ return x * (x <= 0.f ? -1.f : 1.f);
+}
+float i1(float x)
+{
+ return x * (x <= 0.f ? 1.f : -1.f);
+}
+/* { dg-final { scan-tree-dump-times "ABS" 8 "gimple"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
index 3c8ee06016f..0fa5600177e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
@@ -1,15 +1,15 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -Wunsafe-loop-optimizations" } */
+/* { dg-options "-O2 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */
extern void g(void);
void
f (unsigned n)
{
unsigned k;
- for(k = 0;k <= n;k++) /* { dg-warning "missed loop optimization.*overflow" } */
+ for(k = 0;k <= n;k++) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
g();
- for(k = 0;k <= n;k += 4) /* { dg-warning "missed loop optimization.*overflow" } */
+ for(k = 0;k <= n;k += 4) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
g();
/* We used to get warning for this loop. However, since then # of iterations
@@ -21,9 +21,9 @@ f (unsigned n)
g();
/* So we need the following loop, instead. */
- for(k = 4;k <= n;k += 5) /* { dg-warning "missed loop optimization.*overflow" } */
+ for(k = 4;k <= n;k += 5) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
g();
- for(k = 15;k >= n;k--) /* { dg-warning "missed loop optimization.*overflow" } */
+ for(k = 15;k >= n;k--) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
g();
}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81346-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-1.c
new file mode 100644
index 00000000000..c766d6ff996
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-1.c
@@ -0,0 +1,37 @@
+/* PR tree-optimization/81346 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "return 1;" 32 "optimized" } } */
+
+int f00 (int x) { return x / 49152 > -49152; }
+int f01 (int x) { int a = 49152, b = -49152; return x / a > b; }
+int f02 (int x) { return x / 49152 >= -49152; }
+int f03 (int x) { int a = 49152, b = -49152; return x / a >= b; }
+int f04 (int x) { return x / 49152 < 49152; }
+int f05 (int x) { int a = 49152, b = 49152; return x / a < b; }
+int f06 (int x) { return x / 49152 <= 49152; }
+int f07 (int x) { int a = 49152, b = 49152; return x / a <= b; }
+int f08 (int x) { return x / 46340 >= -46341; }
+int f09 (int x) { int a = 46340, b = -46341; return x / a >= b; }
+int f10 (int x) { return x / 46340 <= 46341; }
+int f11 (int x) { int a = 46340, b = 46341; return x / a <= b; }
+int f12 (int x) { return x / 49152 != -49152; }
+int f13 (int x) { int a = 49152, b = -49152; return x / a != b; }
+int f14 (int x) { return x / 49152 != 49152; }
+int f15 (int x) { int a = 49152, b = 49152; return x / a != b; }
+int f16 (int x) { return x / -49152 > -49152; }
+int f17 (int x) { int a = -49152, b = -49152; return x / a > b; }
+int f18 (int x) { return x / -49152 >= -49152; }
+int f19 (int x) { int a = -49152, b = -49152; return x / a >= b; }
+int f20 (int x) { return x / -49152 < 49152; }
+int f21 (int x) { int a = -49152, b = 49152; return x / a < b; }
+int f22 (int x) { return x / -49152 <= 49152; }
+int f23 (int x) { int a = -49152, b = 49152; return x / a <= b; }
+int f24 (int x) { return x / -46340 >= -46341; }
+int f25 (int x) { int a = -46340, b = -46341; return x / a >= b; }
+int f26 (int x) { return x / -46340 <= 46341; }
+int f27 (int x) { int a = -46340, b = 46341; return x / a <= b; }
+int f28 (int x) { return x / -49152 != 49152; }
+int f29 (int x) { int a = -49152, b = 49152; return x / a != b; }
+int f30 (int x) { return x / -49152 != -49152; }
+int f31 (int x) { int a = -49152, b = -49152; return x / a != b; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81346-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-2.c
new file mode 100644
index 00000000000..87bad395c3b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-2.c
@@ -0,0 +1,37 @@
+/* PR tree-optimization/81346 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "return 0;" 32 "optimized" } } */
+
+int f00 (int x) { return x / 49152 > 49152; }
+int f01 (int x) { int a = 49152, b = 49152; return x / a > b; }
+int f02 (int x) { return x / 49152 >= 49152; }
+int f03 (int x) { int a = 49152, b = 49152; return x / a >= b; }
+int f04 (int x) { return x / 49152 < -49152; }
+int f05 (int x) { int a = 49152, b = -49152; return x / a < b; }
+int f06 (int x) { return x / 49152 <= -49152; }
+int f07 (int x) { int a = 49152, b = -49152; return x / a <= b; }
+int f08 (int x) { return x / 46340 > 46341; }
+int f09 (int x) { int a = 46340, b = 46341; return x / a > b; }
+int f10 (int x) { return x / 46340 < -46341; }
+int f11 (int x) { int a = 46340, b = -46341; return x / a < b; }
+int f12 (int x) { return x / 49152 == -49152; }
+int f13 (int x) { int a = 49152, b = -49152; return x / a == b; }
+int f14 (int x) { return x / 49152 == 49152; }
+int f15 (int x) { int a = 49152, b = 49152; return x / a == b; }
+int f16 (int x) { return x / -49152 > 49152; }
+int f17 (int x) { int a = -49152, b = 49152; return x / a > b; }
+int f18 (int x) { return x / -49152 >= 49152; }
+int f19 (int x) { int a = -49152, b = 49152; return x / a >= b; }
+int f20 (int x) { return x / -49152 < -49152; }
+int f21 (int x) { int a = -49152, b = -49152; return x / a < b; }
+int f22 (int x) { return x / -49152 <= -49152; }
+int f23 (int x) { int a = -49152, b = -49152; return x / a <= b; }
+int f24 (int x) { return x / -46340 > 46341; }
+int f25 (int x) { int a = -46340, b = 46341; return x / a > b; }
+int f26 (int x) { return x / -46340 < -46341; }
+int f27 (int x) { int a = -46340, b = -46341; return x / a < b; }
+int f28 (int x) { return x / -49152 == 49152; }
+int f29 (int x) { int a = -49152, b = 49152; return x / a == b; }
+int f30 (int x) { return x / -49152 == -49152; }
+int f31 (int x) { int a = -49152, b = -49152; return x / a == b; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81346-3.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-3.c
new file mode 100644
index 00000000000..bef64a8746a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-3.c
@@ -0,0 +1,109 @@
+/* PR tree-optimization/81346 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-not " / " "optimized" } } */
+
+__attribute__((noinline, noclone)) int f00 (int x) { return x / 46340 > -46341; }
+__attribute__((noinline, noclone)) int f01 (int x) { int a = 46340, b = -46341; return x / a > b; }
+__attribute__((noinline, noclone)) int f02 (int x) { return x / 46340 >= 46341; }
+__attribute__((noinline, noclone)) int f03 (int x) { int a = 46340, b = 46341; return x / a >= b; }
+__attribute__((noinline, noclone)) int f04 (int x) { return x / 46340 < 46341; }
+__attribute__((noinline, noclone)) int f05 (int x) { int a = 46340, b = 46341; return x / a < b; }
+__attribute__((noinline, noclone)) int f06 (int x) { return x / 46340 <= -46341; }
+__attribute__((noinline, noclone)) int f07 (int x) { int a = 46340, b = -46341; return x / a <= b; }
+__attribute__((noinline, noclone)) int f08 (int x) { return x / 46340 == -46341; }
+__attribute__((noinline, noclone)) int f09 (int x) { int a = 46340, b = -46341; return x / a == b; }
+__attribute__((noinline, noclone)) int f10 (int x) { return x / 46340 == 46341; }
+__attribute__((noinline, noclone)) int f11 (int x) { int a = 46340, b = 46341; return x / a == b; }
+__attribute__((noinline, noclone)) int f12 (int x) { return x / 46340 != -46341; }
+__attribute__((noinline, noclone)) int f13 (int x) { int a = 46340, b = -46341; return x / a != b; }
+__attribute__((noinline, noclone)) int f14 (int x) { return x / 46340 != 46341; }
+__attribute__((noinline, noclone)) int f15 (int x) { int a = 46340, b = 46341; return x / a != b; }
+__attribute__((noinline, noclone)) int f16 (int x) { return x / 15 > -15; }
+__attribute__((noinline, noclone)) int f17 (int x) { int a = 15, b = -15; return x / a > b; }
+__attribute__((noinline, noclone)) int f18 (int x) { return x / 15 > 15; }
+__attribute__((noinline, noclone)) int f19 (int x) { int a = 15, b = 15; return x / a > b; }
+__attribute__((noinline, noclone)) int f20 (int x) { return x / 15 >= -15; }
+__attribute__((noinline, noclone)) int f21 (int x) { int a = 15, b = -15; return x / a >= b; }
+__attribute__((noinline, noclone)) int f22 (int x) { return x / 15 >= 15; }
+__attribute__((noinline, noclone)) int f23 (int x) { int a = 15, b = 15; return x / a >= b; }
+__attribute__((noinline, noclone)) int f24 (int x) { return x / 15 < -15; }
+__attribute__((noinline, noclone)) int f25 (int x) { int a = 15, b = -15; return x / a < b; }
+__attribute__((noinline, noclone)) int f26 (int x) { return x / 15 < 15; }
+__attribute__((noinline, noclone)) int f27 (int x) { int a = 15, b = 15; return x / a < b; }
+__attribute__((noinline, noclone)) int f28 (int x) { return x / 15 <= -15; }
+__attribute__((noinline, noclone)) int f29 (int x) { int a = 15, b = -15; return x / a <= b; }
+__attribute__((noinline, noclone)) int f30 (int x) { return x / 15 <= 15; }
+__attribute__((noinline, noclone)) int f31 (int x) { int a = 15, b = 15; return x / a <= b; }
+__attribute__((noinline, noclone)) int f32 (int x) { return x / 15 == -15; }
+__attribute__((noinline, noclone)) int f33 (int x) { int a = 15, b = -15; return x / a == b; }
+__attribute__((noinline, noclone)) int f34 (int x) { return x / 15 == 15; }
+__attribute__((noinline, noclone)) int f35 (int x) { int a = 15, b = 15; return x / a == b; }
+__attribute__((noinline, noclone)) int f36 (int x) { return x / 15 != -15; }
+__attribute__((noinline, noclone)) int f37 (int x) { int a = 15, b = -15; return x / a != b; }
+__attribute__((noinline, noclone)) int f38 (int x) { return x / 15 != 15; }
+__attribute__((noinline, noclone)) int f39 (int x) { int a = 15, b = 15; return x / a != b; }
+__attribute__((noinline, noclone)) int f40 (int x) { return x / -46340 > -46341; }
+__attribute__((noinline, noclone)) int f41 (int x) { int a = -46340, b = -46341; return x / a > b; }
+__attribute__((noinline, noclone)) int f42 (int x) { return x / -46340 >= 46341; }
+__attribute__((noinline, noclone)) int f43 (int x) { int a = -46340, b = 46341; return x / a >= b; }
+__attribute__((noinline, noclone)) int f44 (int x) { return x / -46340 < 46341; }
+__attribute__((noinline, noclone)) int f45 (int x) { int a = -46340, b = 46341; return x / a < b; }
+__attribute__((noinline, noclone)) int f46 (int x) { return x / -46340 <= -46341; }
+__attribute__((noinline, noclone)) int f47 (int x) { int a = -46340, b = -46341; return x / a <= b; }
+__attribute__((noinline, noclone)) int f48 (int x) { return x / -46340 == 46341; }
+__attribute__((noinline, noclone)) int f49 (int x) { int a = -46340, b = 46341; return x / a == b; }
+__attribute__((noinline, noclone)) int f50 (int x) { return x / -46340 == -46341; }
+__attribute__((noinline, noclone)) int f51 (int x) { int a = -46340, b = -46341; return x / a == b; }
+__attribute__((noinline, noclone)) int f52 (int x) { return x / -46340 != 46341; }
+__attribute__((noinline, noclone)) int f53 (int x) { int a = -46340, b = 46341; return x / a != b; }
+__attribute__((noinline, noclone)) int f54 (int x) { return x / -46340 != -46341; }
+__attribute__((noinline, noclone)) int f55 (int x) { int a = -46340, b = -46341; return x / a != b; }
+__attribute__((noinline, noclone)) int f56 (int x) { return x / -15 > 15; }
+__attribute__((noinline, noclone)) int f57 (int x) { int a = -15, b = 15; return x / a > b; }
+__attribute__((noinline, noclone)) int f58 (int x) { return x / -15 > -15; }
+__attribute__((noinline, noclone)) int f59 (int x) { int a = -15, b = -15; return x / a > b; }
+__attribute__((noinline, noclone)) int f60 (int x) { return x / -15 >= 15; }
+__attribute__((noinline, noclone)) int f61 (int x) { int a = -15, b = 15; return x / a >= b; }
+__attribute__((noinline, noclone)) int f62 (int x) { return x / -15 >= -15; }
+__attribute__((noinline, noclone)) int f63 (int x) { int a = -15, b = -15; return x / a >= b; }
+__attribute__((noinline, noclone)) int f64 (int x) { return x / -15 < 15; }
+__attribute__((noinline, noclone)) int f65 (int x) { int a = -15, b = 15; return x / a < b; }
+__attribute__((noinline, noclone)) int f66 (int x) { return x / -15 < -15; }
+__attribute__((noinline, noclone)) int f67 (int x) { int a = -15, b = -15; return x / a < b; }
+__attribute__((noinline, noclone)) int f68 (int x) { return x / -15 <= 15; }
+__attribute__((noinline, noclone)) int f69 (int x) { int a = -15, b = 15; return x / a <= b; }
+__attribute__((noinline, noclone)) int f70 (int x) { return x / -15 <= -15; }
+__attribute__((noinline, noclone)) int f71 (int x) { int a = -15, b = -15; return x / a <= b; }
+__attribute__((noinline, noclone)) int f72 (int x) { return x / -15 == 15; }
+__attribute__((noinline, noclone)) int f73 (int x) { int a = -15, b = 15; return x / a == b; }
+__attribute__((noinline, noclone)) int f74 (int x) { return x / -15 == -15; }
+__attribute__((noinline, noclone)) int f75 (int x) { int a = -15, b = -15; return x / a == b; }
+__attribute__((noinline, noclone)) int f76 (int x) { return x / -15 != 15; }
+__attribute__((noinline, noclone)) int f77 (int x) { int a = -15, b = 15; return x / a != b; }
+__attribute__((noinline, noclone)) int f78 (int x) { return x / -15 != -15; }
+__attribute__((noinline, noclone)) int f79 (int x) { int a = -15, b = -15; return x / a != b; }
+__attribute__((noinline, noclone)) int f80 (int x) { return x / -15 > 0; }
+__attribute__((noinline, noclone)) int f81 (int x) { int a = -15, b = 0; return x / a > b; }
+__attribute__((noinline, noclone)) int f82 (int x) { return x / 15 > 0; }
+__attribute__((noinline, noclone)) int f83 (int x) { int a = 15, b = 0; return x / a > b; }
+__attribute__((noinline, noclone)) int f84 (int x) { return x / -15 >= 0; }
+__attribute__((noinline, noclone)) int f85 (int x) { int a = -15, b = 0; return x / a >= b; }
+__attribute__((noinline, noclone)) int f86 (int x) { return x / 15 >= 0; }
+__attribute__((noinline, noclone)) int f87 (int x) { int a = 15, b = 0; return x / a >= b; }
+__attribute__((noinline, noclone)) int f88 (int x) { return x / -15 < 0; }
+__attribute__((noinline, noclone)) int f89 (int x) { int a = -15, b = 0; return x / a < b; }
+__attribute__((noinline, noclone)) int f90 (int x) { return x / 15 < 0; }
+__attribute__((noinline, noclone)) int f91 (int x) { int a = 15, b = 0; return x / a < b; }
+__attribute__((noinline, noclone)) int f92 (int x) { return x / -15 <= 0; }
+__attribute__((noinline, noclone)) int f93 (int x) { int a = -15, b = 0; return x / a <= b; }
+__attribute__((noinline, noclone)) int f94 (int x) { return x / 15 <= 0; }
+__attribute__((noinline, noclone)) int f95 (int x) { int a = 15, b = 0; return x / a <= b; }
+__attribute__((noinline, noclone)) int f96 (int x) { return x / -15 == 0; }
+__attribute__((noinline, noclone)) int f97 (int x) { int a = -15, b = 0; return x / a == b; }
+__attribute__((noinline, noclone)) int f98 (int x) { return x / 15 == 0; }
+__attribute__((noinline, noclone)) int f99 (int x) { int a = 15, b = 0; return x / a == b; }
+__attribute__((noinline, noclone)) int f100 (int x) { return x / -15 != 0; }
+__attribute__((noinline, noclone)) int f101 (int x) { int a = -15, b = 0; return x / a != b; }
+__attribute__((noinline, noclone)) int f102 (int x) { return x / 15 != 0; }
+__attribute__((noinline, noclone)) int f103 (int x) { int a = 15, b = 0; return x / a != b; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81346-4.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-4.c
new file mode 100644
index 00000000000..f93ad468c3f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-4.c
@@ -0,0 +1,79 @@
+/* PR tree-optimization/81346 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "pr81346-3.c"
+
+#define INT_MAX __INT_MAX__
+#define INT_MIN (-__INT_MAX__ - 1)
+
+extern void abort (void);
+
+int
+main ()
+{
+ if (__CHAR_BIT__ != 8 || __SIZEOF_INT__ != 4)
+ return 0;
+#define TEST(fn1, fn2, v1, v2) \
+ do { \
+ int w1 = v1; int w2 = v2; \
+ int in = 1; if (w1 > w2) { in = w1; w1 = w2; w2 = in; in = 0; } \
+ if (w1 != INT_MIN) { if (fn1 (w1 - 1) != !in || fn2 (w1 - 1) != !in) abort (); } \
+ if (fn1 (w1) != in || fn2 (w1) != in) abort (); \
+ if (fn1 (w2) != in || fn2 (w2) != in) abort (); \
+ if (w2 != INT_MAX) { if (fn1 (w2 + 1) != !in || fn2 (w2 + 1) != !in) abort (); } \
+ } while (0)
+TEST (f00, f01, -2147441939, INT_MAX);
+TEST (f02, f03, 2147441940, INT_MAX);
+TEST (f04, f05, INT_MIN, 2147441939);
+TEST (f06, f07, INT_MIN, -2147441940);
+TEST (f08, f09, INT_MIN, -2147441940);
+TEST (f10, f11, 2147441940, INT_MAX);
+TEST (f12, f13, -2147441939, INT_MAX);
+TEST (f14, f15, INT_MIN, 2147441939);
+TEST (f16, f17, -224, INT_MAX);
+TEST (f18, f19, 240, INT_MAX);
+TEST (f20, f21, -239, INT_MAX);
+TEST (f22, f23, 225, INT_MAX);
+TEST (f24, f25, INT_MIN, -240);
+TEST (f26, f27, INT_MIN, 224);
+TEST (f28, f29, INT_MIN, -225);
+TEST (f30, f31, INT_MIN, 239);
+TEST (f32, f33, -239, -225);
+TEST (f34, f35, 225, 239);
+TEST (f36, f37, -225, -239);
+TEST (f38, f39, 239, 225);
+TEST (f40, f41, INT_MIN, 2147441939);
+TEST (f42, f43, INT_MIN, -2147441940);
+TEST (f44, f45, -2147441939, INT_MAX);
+TEST (f46, f47, 2147441940, INT_MAX);
+TEST (f48, f49, INT_MIN, -2147441940);
+TEST (f50, f51, 2147441940, INT_MAX);
+TEST (f52, f53, -2147441939, INT_MAX);
+TEST (f54, f55, INT_MIN, 2147441939);
+TEST (f56, f57, INT_MIN, -240);
+TEST (f58, f59, INT_MIN, 224);
+TEST (f60, f61, INT_MIN, -225);
+TEST (f62, f63, INT_MIN, 239);
+TEST (f64, f65, -224, INT_MAX);
+TEST (f66, f67, 240, INT_MAX);
+TEST (f68, f69, -239, INT_MAX);
+TEST (f70, f71, 225, INT_MAX);
+TEST (f72, f73, -239, -225);
+TEST (f74, f75, 225, 239);
+TEST (f76, f77, -225, -239);
+TEST (f78, f79, 239, 225);
+TEST (f80, f81, INT_MIN, -15);
+TEST (f82, f83, 15, INT_MAX);
+TEST (f84, f85, INT_MIN, 14);
+TEST (f86, f87, -14, INT_MAX);
+TEST (f88, f89, 15, INT_MAX);
+TEST (f90, f91, INT_MIN, -15);
+TEST (f92, f93, -14, INT_MAX);
+TEST (f94, f95, INT_MIN, 14);
+TEST (f96, f97, -14, 14);
+TEST (f98, f99, -14, 14);
+TEST (f100, f101, 14, -14);
+TEST (f102, f103, 14, -14);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81346-5.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-5.c
new file mode 100644
index 00000000000..14562a11152
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81346-5.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/81346 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "\\(signed int\\) x" 10 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " <= 0;" 5 "optimized" } } */
+/* { dg-final { scan-tree-dump-times " > 0;" 5 "optimized" } } */
+
+int f1 (unsigned x) { return x - 1 <= __INT_MAX__ - 1; }
+int f2 (unsigned x) { unsigned a = 1, b = __INT_MAX__ - 1; return x - a <= b; }
+int f3 (unsigned x) { return x - 1 < __INT_MAX__; }
+int f4 (unsigned x) { unsigned a = 1, b = __INT_MAX__; return x - a < b; }
+int f5 (unsigned x) { return x >= 1 && x <= __INT_MAX__; }
+int f6 (unsigned x) { return x - 1 > __INT_MAX__ - 1; }
+int f7 (unsigned x) { unsigned a = 1, b = __INT_MAX__ - 1; return x - a > b; }
+int f8 (unsigned x) { return x - 1 >= __INT_MAX__; }
+int f9 (unsigned x) { unsigned a = 1, b = __INT_MAX__; return x - a >= b; }
+int f10 (unsigned x) { return x < 1 || x > __INT_MAX__; }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81369.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81369.c
new file mode 100644
index 00000000000..b40477b0b41
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81369.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-distribution" } */
+
+typedef __PTRDIFF_TYPE__ intptr_t;
+int wo;
+
+void
+sy (long int *as)
+{
+ for (;;)
+ {
+ *as = wo;
+ while (as < (long int *) (void *) 2)
+ {
+ int *y9;
+
+ if (wo != 0)
+ *y9 = (int) (intptr_t) &wo;
+ wo /= (wo != 0 && *y9 != 0);
+ ++as;
+ }
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81388-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81388-1.c
new file mode 100644
index 00000000000..ecfe12929cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81388-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-strict-overflow -fdump-tree-ivcanon-details" } */
+
+void bar();
+void foo(char *dst)
+{
+ char *const end = dst;
+ do {
+ bar();
+ dst += 2;
+ } while (dst < end);
+}
+
+/* { dg-final { scan-tree-dump-times " zero if " 1 "ivcanon" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81388-2.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81388-2.c
new file mode 100644
index 00000000000..71fd2890f3d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81388-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-ivcanon-details" } */
+
+void bar();
+void foo(unsigned dst)
+{
+ unsigned end = dst;
+ do {
+ bar();
+ dst += 2;
+ } while (dst < end);
+}
+
+/* { dg-final { scan-tree-dump-times " zero if " 1 "ivcanon" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr81396.c b/gcc/testsuite/gcc.dg/tree-ssa/pr81396.c
new file mode 100644
index 00000000000..9f4a08d1c22
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr81396.c
@@ -0,0 +1,25 @@
+/* PR tree-optimization/81396 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+typedef unsigned long long uint64_t;
+
+uint64_t
+foo (uint64_t word)
+{
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ && __SIZEOF_LONG_LONG__ == 8
+ const unsigned char *const ptr = (const unsigned char *) &word;
+ return ((uint64_t) ptr[0]
+ | ((uint64_t) ptr[1] << 8)
+ | ((uint64_t) ptr[2] << (8 * 2))
+ | ((uint64_t) ptr[3] << (8 * 3))
+ | ((uint64_t) ptr[4] << (8 * 4))
+ | ((uint64_t) ptr[5] << (8 * 5))
+ | ((uint64_t) ptr[6] << (8 * 6))
+ | ((uint64_t) ptr[7] << (8 * 7)));
+#else
+ return word;
+#endif
+}
+
+/* { dg-final { scan-tree-dump "return word_\[0-9]*\\(D\\);" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-1.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-1.c
new file mode 100644
index 00000000000..d3a2339e55e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-1.c
@@ -0,0 +1,62 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11};
+int result0[10] = {2, 3, 5, 7, 11};
+int result1[10] = {0, -1, 5, -2, 11, 0};
+int result2[10] = {0, 0, -1, -2, -2, 0};
+int result3[10] = {0, 0, 0, -1, -2, -2, 0};
+int result4[10] = {0, 0, 0, 0, -1, -2, -2, 0};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, 0};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 3] = -2;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-10.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-10.c
new file mode 100644
index 00000000000..bd5575d9502
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-10.c
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11};
+int result0[10] = {2, 3, 5, 7, 11};
+int result1[10] = {0, 3, 5, -2, 11, 0};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len, int flag)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ if (flag)
+ a[i + 1] = -1;
+ a[i + 3] = -2;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ int i;
+
+ foo (arr, 0, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1, 0);
+ check (arr, result1, 10);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump-not "Store-stores chain" "pcom"} } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-11.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-11.c
new file mode 100644
index 00000000000..9e496f68a12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-11.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11};
+int x[105] = {2, 3, 5, 7, 11};
+int result0[10] = {2, 3, 5, 7, 11};
+int result1[10] = {0, 0, 0, 0, 0, 0, -1, -2, -2};
+
+extern void abort (void);
+
+int __attribute__((noinline)) foo (int * __restrict__ a, int * __restrict__ b, int len, int flag)
+{
+ int i, sum = 0;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ b[i + 2] = i;
+ a[i + 1] = -1;
+ sum += b[i];
+ a[i + 3] = -2;
+ }
+ return sum;
+}
+
+void check (int *a, int *res, int len, int sum, int val)
+{
+ int i;
+
+ if (sum != val)
+ abort ();
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ int i, sum;
+
+ sum = foo (arr, x, 0, 0);
+ check (arr, result0, 10, sum, 0);
+
+ sum = foo (arr, x, 6, 0);
+ check (arr, result1, 10, sum, 11);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
+/* { dg-final { scan-tree-dump "Store-loads chain" "pcom"} } */
+
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-2.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-2.c
new file mode 100644
index 00000000000..c48d438e9e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-2.c
@@ -0,0 +1,62 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11};
+int result0[10] = {2, 3, 5, 7, 11};
+int result1[10] = {0, 3, -1, -2, 11, 0};
+int result2[10] = {0, 0, -1, -1, -2, 0};
+int result3[10] = {0, 0, 0, -1, -1, -2, 0};
+int result4[10] = {0, 0, 0, 0, -1, -1, -2, 0};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -2, 0};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 2] = -1;
+ a[i + 3] = -2;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-3.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-3.c
new file mode 100644
index 00000000000..9c2736cd0ad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-3.c
@@ -0,0 +1,108 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr1[105] = {2, 3, 5, 7, 11, 13, 0};
+int arr2[105] = {2, 3, 5, 7, 11, 13, 0};
+int arr3[105] = {2, 3, 5, 7, 11, 13, 0};
+int arr4[105] = {2, 3, 5, 7, 11, 13, 0};
+int result1[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, 0};
+int result2[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -2, 0};
+int result3[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, 0};
+int result4[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0};
+
+extern void abort (void);
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+void __attribute__((noinline)) foo1 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 2] = -2;
+ a[i + 3] = -3;
+ }
+}
+
+void __attribute__((noinline)) foo2 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 2] = -1;
+ a[i + 3] = -2;
+ }
+}
+
+void __attribute__((noinline)) foo3 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 3] = -2;
+ }
+}
+
+void __attribute__((noinline)) foo4 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 3] = -1;
+ }
+}
+
+int main (void)
+{
+ foo1 (arr1);
+ check (arr1, result1, 105);
+
+ foo2 (arr2);
+ check (arr2, result2, 105);
+
+ foo3 (arr3);
+ check (arr3, result3, 105);
+
+ foo4 (arr4);
+ check (arr4, result4, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump-times "Store-stores chain" 4 "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-4.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-4.c
new file mode 100644
index 00000000000..302425a17cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-4.c
@@ -0,0 +1,61 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11};
+int result0[10] = {2, 3, 5, 7, 11};
+int result1[10] = {0, 3, 5, -1, 11, 0};
+int result2[10] = {0, 0, 5, -1, -1, 0};
+int result3[10] = {0, 0, 0, -1, -1, -1, 0};
+int result4[10] = {0, 0, 0, 0, -1, -1, -1, 0};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 3] = -1;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-5.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-5.c
new file mode 100644
index 00000000000..a13d56098be
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-5.c
@@ -0,0 +1,63 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11};
+int result0[10] = {2, 3, 5, 7, 11};
+int result1[10] = {0, -1, -2, -3, 11, 0};
+int result2[10] = {0, 0, -1, -2, -3, 0};
+int result3[10] = {0, 0, 0, -1, -2, -3, 0};
+int result4[10] = {0, 0, 0, 0, -1, -2, -3, 0};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, 0};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 2] = -2;
+ a[i + 3] = -3;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-6.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-6.c
new file mode 100644
index 00000000000..63d6c8f33b0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-6.c
@@ -0,0 +1,65 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
+int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
+int result1[10] = {0, -1, -2, -3, -4, -5, 17, 19};
+int result2[10] = {0, 0, -1, -2, -3, -4, -5, 19};
+int result3[10] = {0, 0, 0, -1, -2, -3, -4, -5};
+int result4[10] = {0, 0, 0, 0, -1, -2, -3, -4, -5};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 2] = -2;
+ a[i + 3] = -3;
+ a[i + 4] = -4;
+ a[i + 5] = -5;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-7.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-7.c
new file mode 100644
index 00000000000..0bde6e6dced
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-7.c
@@ -0,0 +1,63 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
+int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
+int result1[10] = {0, -1, 5, -3, 11, -5, 17, 19};
+int result2[10] = {0, 0, -1, -3, -3, -5, -5, 19};
+int result3[10] = {0, 0, 0, -1, -3, -3, -5, -5};
+int result4[10] = {0, 0, 0, 0, -1, -3, -3, -5, -5};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -3, -3, -5, -5};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 3] = -3;
+ a[i + 5] = -5;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-8.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-8.c
new file mode 100644
index 00000000000..45ffd25c424
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-8.c
@@ -0,0 +1,60 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
+int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
+int result1[10] = {0, 3, 5, 7, 11, -5, 17, 19};
+int result2[10] = {0, 0, 5, 7, 11, -5, -5, 19};
+int result3[10] = {0, 0, 0, 7, 11, -5, -5, -5};
+int result4[10] = {0, 0, 0, 0, 11, -5, -5, -5, -5};
+int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, -5};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo (int *a, int len)
+{
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ a[i] = 0;
+ a[i + 5] = -5;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo (arr, 0);
+ check (arr, result0, 10);
+
+ foo (arr, 1);
+ check (arr, result1, 10);
+
+ foo (arr, 2);
+ check (arr, result2, 10);
+
+ foo (arr, 3);
+ check (arr, result3, 10);
+
+ foo (arr, 4);
+ check (arr, result4, 10);
+
+ foo (arr, 100);
+ check (arr, result100, 105);
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-9.c b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-9.c
new file mode 100644
index 00000000000..1c4e3140309
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/predcom-dse-9.c
@@ -0,0 +1,90 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
+
+int arr1[105] = {2, 3, 5, 7, 11, 13, 17, 19};
+int arr2[105] = {2, 3, 5, 7, 11, 13, 17, 19};
+int arr3[105] = {2, 3, 5, 7, 11, 13, 17, 19};
+
+int result1[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5};
+int result2[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -3, -3, -5, -5};
+int result3[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, -5};
+
+extern void abort (void);
+
+void __attribute__((noinline)) foo1 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 2] = -2;
+ a[i + 3] = -3;
+ a[i + 4] = -4;
+ a[i + 5] = -5;
+ }
+}
+
+void __attribute__((noinline)) foo2 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 1] = -1;
+ a[i + 3] = -3;
+ a[i + 5] = -5;
+ }
+}
+
+void __attribute__((noinline)) foo3 (int *a)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ a[i] = 0;
+ a[i + 5] = -5;
+ }
+}
+
+void check (int *a, int *res, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ if (a[i] != res[i])
+ abort ();
+}
+
+int main (void)
+{
+ foo1 (arr1);
+ check (arr1, result1, 10);
+
+ foo2 (arr2);
+ check (arr2, result2, 10);
+
+ foo3 (arr3);
+ check (arr3, result3, 10);
+
+ return 0;
+}
+/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/slsr-35.c b/gcc/testsuite/gcc.dg/tree-ssa/slsr-35.c
index 9a7d8d5d253..0f57ea20b79 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/slsr-35.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/slsr-35.c
@@ -3,7 +3,7 @@
phi has an argument which is a parameter. */
/* { dg-do compile } */
-/* { dg-options "-O3 -fno-code-hoisting -fdump-tree-optimized" } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
int
f (int c, int i)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/slsr-36.c b/gcc/testsuite/gcc.dg/tree-ssa/slsr-36.c
index 1ab357d11c0..448d5d2cff1 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/slsr-36.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/slsr-36.c
@@ -3,7 +3,7 @@
phi has an argument which is a parameter. */
/* { dg-do compile } */
-/* { dg-options "-O3 -fno-code-hoisting -fdump-tree-optimized" } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
int
f (int s, int c, int i)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/slsr-4.c b/gcc/testsuite/gcc.dg/tree-ssa/slsr-4.c
index 17d7b4c6951..1e943b737b9 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/slsr-4.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/slsr-4.c
@@ -23,13 +23,9 @@ f (int i)
foo (y);
}
-/* { dg-final { scan-tree-dump-times "\\* 4" 1 "slsr" } } */
-/* { dg-final { scan-tree-dump-times "\\* 10" 1 "slsr" } } */
-/* { dg-final { scan-tree-dump-times "\\+ 20;" 1 "slsr" } } */
+/* { dg-final { scan-tree-dump-times "\\* 40" 1 "slsr" } } */
/* { dg-final { scan-tree-dump-times "\\+ 200" 1 "slsr" } } */
-/* { dg-final { scan-tree-dump-times "\\- 16;" 1 "slsr" } } */
/* { dg-final { scan-tree-dump-times "\\- 160" 1 "slsr" } } */
-/* { dg-final { scan-tree-dump-times "\\* 4" 1 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "\\* 10" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\\* 40" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "\\+ 200" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "\\+ 40" 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-30.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-30.c
index ece8cb2a80c..1d1fe82fda0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-30.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-30.c
@@ -8,7 +8,7 @@ void test_bcopy (const void *s)
{
char d[33];
- /* Bcopy is transformed into memcpy and those calls are expanded
+ /* Bcopy is transformed into memmove and those calls are expanded
inline in EVRP, before DSE runs, so this test doesn't actually
verify that DSE does its job. */
__builtin_bcopy (s, d, sizeof d);
@@ -28,4 +28,4 @@ void test_bzero (void)
}
/* { dg-final { scan-tree-dump-times "builtin_memset" 1 "dse1" } } */
-/* { dg-final { scan-tree-dump-not "builtin_(bcopy|bzero|memcpy)" "dse1" } } */
+/* { dg-final { scan-tree-dump-not "builtin_(bcopy|bzero|memcpy|memmove)" "dse1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c
new file mode 100644
index 00000000000..d9d7b2394cd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp116.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+int
+f (int m1, int m2, int c)
+{
+ int d = m1 > m2;
+ int e = d * c;
+ return e ? m1 : m2;
+}
+
+/* { dg-final { scan-tree-dump-times "\\? c_\[0-9\]\\(D\\) : 0" 1 "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
index 853ee21bb8f..ed49e25f87a 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details -fdump-tree-optimized" } */
struct rtx_def;
@@ -86,10 +86,8 @@ L7:
/* The first n_sets > 0 test can be simplfiied into n_sets == 1 since
n_sets can only have the values [0, 1] as it's the result of a
- boolean operation.
+ boolean operation. */
- The second n_sets > 0 test can also be simplified into n_sets == 1
- as the only way to reach the tests is when n_sets <= 1 and the only
- value which satisfies both conditions is n_sets == 1. */
-/* { dg-final { scan-tree-dump-times "Simplified relational" 2 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "if " 4 "optimized" } } */