Consider: int foo (unsigned long a) { int b = __builtin_clzl (a); int c = __builtin_clzl (a); if (b == c) return 1; return 0; } Here is what I get after FRE. foo (a) { int c; int b; int D.1235; <bb 0>: b_3 = __builtin_clzl (a_2); c_4 = __builtin_clzl (a_2); if (b_3 == c_4) goto <L0>; else goto <L1>; <L0>:; D.1235_7 = 1; goto <bb 3> (<L2>); <L1>:; D.1235_6 = 0; # D.1235_1 = PHI <1(1), 0(2)>; <L2>:; return D.1235_1; } DOM catches this later.
Confirmed, here is another testcase (for -ffast-math): double cos (double); void link_error(); void f(double a) { double b = cos (a); double c = cos (a); if (b!=c) link_error(); }
Subject: Re: FRE does not eliminate a redundant builtin call. On Sat, 2005-05-14 at 21:30 +0000, pinskia at gcc dot gnu dot org wrote: > ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-14 21:30 ------- > Confirmed, here is another testcase (for -ffast-math): > double cos (double); > void link_error(); > void f(double a) > { > double b = cos (a); > double c = cos (a); > if (b!=c) > link_error(); > } > Yes, we should make the result of a CONST call available, but don't.
Subject: Bug 21576 CVSROOT: /cvs/gcc Module name: gcc Changes by: dberlin@gcc.gnu.org 2005-05-16 01:12:09 Modified files: gcc : ChangeLog tree-ssa-pre.c tree-vn.c gcc/testsuite/gcc.dg/tree-ssa: ssa-dom-cse-1.c Added files: gcc/testsuite/gcc.dg/tree-ssa: ssa-pre-10.c ssa-pre-11.c ssa-pre-12.c ssa-pre-13.c ssa-pre-9.c Log message: 2005-05-15 Daniel Berlin <dberlin@dberlin.org> Fix PR tree-optimization/21576 * tree-ssa-pre.c (expression_node_pool): New pool. (comparison_node_pool): Ditto. (list_node_pool): Ditto. (pool_copy_list): New function. (phi_translate): Handle CALL_EXPR. (valid_in_set): Ditto. (create_expression_by_pieces): Ditto. (insert_into_preds_of_block): Ditto. (insert_aux): Ditto. (compute_avail): Ditto. (create_value_expr_from): Handle TREE_LIST and CALL_EXPR. (can_value_number_call): New function. (find_leader): Update comment. (init_pre): Create new pools. (fini_pre): Free new pools. (pass_pre): Add TODO_update_ssa for the future when we are going to need vops. * tree-vn.c (expressions_equal_p): Handle TREE_LIST. (set_value_handle): Ditto. (get_value_handle): Ditto. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8792&r2=2.8793 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-ssa-pre.c.diff?cvsroot=gcc&r1=2.86&r2=2.87 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-vn.c.diff?cvsroot=gcc&r1=2.10&r2=2.11 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-10.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-11.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-12.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-13.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-9.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-1.c.diff?cvsroot=gcc&r1=1.4&r2=1.5
I fixed it, and made it PRE calls too