This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Fix missed PRE optimization discovered
- From: "Daniel Berlin" <dberlin at dberlin dot org>
- To: "GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Oct 2008 18:26:32 -0400
- Subject: [PATCH]: Fix missed PRE optimization discovered
The attached fixes a missed optimization in PRE noticed by richard guenther.
We weren't caching phi translation results if they were constants,
which would cause us to fail to optimize things like:
int main(int argc)
{
int i;
if (argc)
i = 5;
else
i = 9;
y = __builtin_pow(i, i);
return y;
}
the result of phi translation would end up being constant, and we
would throw it away, which would cause us to assume phi translation
had failed.
Fixed by also adding constants to the phi translation table.
This is a regression from 4.3 for some cases, so i am committing it to mainline.
Bootstrapped and regtested on i686-darwin, committed.
2008-10-16 Daniel Berlin <dberlin@dberlin.org>
* tree-ssa-pre.c (phi_translate_set): Add constants to phi
translation cache.
diff -r 2b8e288bbb69 gcc/tree-ssa-pre.c
--- a/gcc/tree-ssa-pre.c Wed Oct 15 16:48:13 2008 +0000
+++ b/gcc/tree-ssa-pre.c Thu Oct 16 18:22:34 2008 -0400
@@ -1745,9 +1745,8 @@
pre_expr translated;
translated = phi_translate (expr, set, NULL, pred, phiblock);
- /* Don't add constants or empty translations to the cache, since
- we won't look them up that way, or use the result, anyway. */
- if (translated && !value_id_constant_p (get_expr_value_id (translated)))
+ /* Don't add empty translations to the cache */
+ if (translated)
phi_trans_add (expr, translated, pred);
if (translated != NULL)