@@ -14,5 +14,5 @@ bar ()
}
/* Two phis for reduction, one in loop header, one in loop exit. One phi for iv
- in loop header. */
-/* { dg-final { scan-tree-dump-times "PHI" 3 "optimized" } } */
+ in loop header. One missed elided for a conversion. */
+/* { dg-final { scan-tree-dump-times "PHI" 4 "optimized" } } */
new file mode 100644
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+short a, *b;
+signed char c, i = 11, j, k, l, m;
+signed char tt;
+__attribute__((noinline)) int t(signed char r) {
+ if (r != 5)
+ __builtin_abort();
+ return 0;
+}
+int main() {
+ short n = 20158;
+ while (1) {
+ b = &n;
+ a = ~n;
+ c = n;
+ if (a < -32255)
+ break;
+ j = n;
+ k = j % i;
+ m = l = 5;
+ m = m * k % i * k;
+ l = l + 8 * k + m;
+ l = l % i;
+ t(l);
+ *b = 6303 + n;
+ }
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+
+short a, *b;
+signed char c, i = 11, j, k, l, m;
+signed char tt;
+__attribute__((noinline)) int t(signed char r) {
+ tt = 1;
+ return 0;
+}
+int main() {
+ short n = 20158;
+ while (1) {
+ a = ~n;
+ c = n;
+ if (a < -32255)
+ break;
+ j = n;
+ k = j % i;
+ m = l = 5;
+ m = m * k % i * k;
+ l = l + 8 * k + m;
+ l = l % i;
+ t(l);
+ n = 6303 + n;
+ }
+ if (l != 5)
+ __builtin_abort ();
+ return 0;
+}
@@ -1425,7 +1425,13 @@ simplify_peeled_chrec (class loop *loop, tree arg, tree init_cond)
/* Transform (init, {left, right}_LOOP)_LOOP to {init, right}_LOOP
if "left" equals to "init + right". */
- if (operand_equal_p (left, step_val, 0))
+ if (operand_equal_p (left, step_val, 0)
+ && ((!POINTER_TYPE_P (type) && !INTEGRAL_TYPE_P (type))
+ || TYPE_OVERFLOW_WRAPS (type)
+ /* When overflow in the type doesn't wrap, make sure the
+ resulting CHREC does not either. */
+ || !scev_probably_wraps_p (NULL_TREE, init_cond, right, NULL,
+ loop, false)))
{
if (dump_file && (dump_flags & TDF_SCEV))
fprintf (dump_file, "Simplify PEELED_CHREC into POLYNOMIAL_CHREC.\n");
@@ -1447,7 +1453,13 @@ simplify_peeled_chrec (class loop *loop, tree arg, tree init_cond)
/* Transform (init, {left, right}_LOOP)_LOOP to {init, right}_LOOP
if "left" equals to "init + right". */
- if (aff_combination_zero_p (&aff1))
+ if (aff_combination_zero_p (&aff1)
+ && ((!POINTER_TYPE_P (type) && !INTEGRAL_TYPE_P (type))
+ || TYPE_OVERFLOW_WRAPS (type)
+ /* When overflow in the type doesn't wrap, make sure the
+ resulting CHREC does not either. */
+ || !scev_probably_wraps_p (NULL_TREE, init_cond, right, NULL,
+ loop, false)))
{
if (dump_file && (dump_flags & TDF_SCEV))
fprintf (dump_file, "Simplify PEELED_CHREC into POLYNOMIAL_CHREC.\n");