PR tree-optimization/3511
* tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that
got new invariant arguments during PHI translation.
* gcc.dg/tree-ssa/ssa-pre-15.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117932
138bc75d-0d04-0410-961f-
82ee72b054a4
2006-10-21 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/3511
+ * tree-ssa-pre.c (phi_translate): Fold CALL_EXPRs that
+ got new invariant arguments during PHI translation.
+
+2006-10-21 Richard Guenther <rguenther@suse.de>
+
PR middle-end/26898
* fold-const.c (fold_comparison): Fold signed comparisons
of the form X +- C1 CMP Y +- C2.
2006-10-21 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/3511
+ * gcc.dg/tree-ssa/ssa-pre-15.c: New testcase.
+
+2006-10-21 Richard Guenther <rguenther@suse.de>
+
PR middle-end/26898
* gcc.dg/torture/pr26898-1.c: New testcase.
* gcc.dg/torture/pr26898-2.c: Likewise.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+/* Verify we PRE the strlen call, as strlen("") folds to zero. */
+
+extern __SIZE_TYPE__ strlen (const char *);
+
+__SIZE_TYPE__ mystrlen (const char *s)
+{
+ if (!s)
+ s = "";
+ return strlen(s);
+}
+
+/* { dg-final { scan-tree-dump "= 0;" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
tree newexpr;
tree vh = get_value_handle (expr);
bool listchanged = false;
+ bool invariantarg = false;
VEC (tree, gc) *vuses = VALUE_HANDLE_VUSES (vh);
VEC (tree, gc) *tvuses;
if (newval != oldval)
{
listchanged = true;
+ invariantarg |= is_gimple_min_invariant (newval);
TREE_VALUE (newwalker) = get_value_handle (newval);
}
}
}
+
+ /* In case of new invariant args we might try to fold the call
+ again. */
+ if (invariantarg)
+ {
+ tree tmp = fold_ternary (CALL_EXPR, TREE_TYPE (expr),
+ newop0, newarglist, newop2);
+ if (tmp)
+ {
+ STRIP_TYPE_NOPS (tmp);
+ if (is_gimple_min_invariant (tmp))
+ return tmp;
+ }
+ }
+
if (listchanged)
vn_lookup_or_add (newarglist, NULL);