Forgot a check for an SSA name before trying to replace a PHI arg with
its current definition.
PR tree-optimization/115197
* tree-loop-distribution.cc (copy_loop_before): Constant PHI
args remain the same.
* gcc.dg/pr115197.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-scev-cprop -ftree-pre -ftree-loop-distribute-patterns" } */
+
+int a, b[2], c, d, e, f[2];
+int main() {
+ while (a)
+ if (d) {
+ if (e)
+ return 0;
+ for (; c; c++)
+ f[c] = 0 < (b[c] = ~(f[c + 1] < a));
+ }
+ return 0;
+}
if (virtual_operand_p (gimple_phi_result (phi)))
continue;
use_operand_p use_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, exit);
- tree new_def = get_current_def (USE_FROM_PTR (use_p));
- SET_USE (use_p, new_def);
+ if (TREE_CODE (USE_FROM_PTR (use_p)) == SSA_NAME)
+ {
+ tree new_def = get_current_def (USE_FROM_PTR (use_p));
+ SET_USE (use_p, new_def);
+ }
}
}