This is the second attempt at solving those PRs which finally allows us
to optimize
std::max(std::min(a0, c), std::min(std::max(a1, c), b))
into a sequence of MIN/MAX exprs and get rid of the previously forced
addressable variables a0, c, a1 and b.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Ok for mainline?
2007-02-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/19431
PR tree-optimization/21463
* tree-pass.h (pass_phiprop): Declare.
* passes.c (init_optimization_passes): New phiprop pass.
* tree-ssa-forwprop.c (struct phiprop_d): New structure.
(phivn_valid_p): New helper function.
(phiprop_insert_phi): Likewise.
(propagate_with_phi): Likewise.
(tree_ssa_phiprop): New propagator propagating loads
through phi nodes if profitable.
(tree_ssa_forward_propagate_single_use_va): Call it.
* gcc.c-torture/execute/20070212-1.c: New testcase.
* gcc.c-torture/execute/20070212-2.c: Likewise.
* gcc.c-torture/execute/20070212-3.c: Likewise.
* gcc.dg/tree-ssa/pr21463.c: Likewise.
* g++.dg/tree-ssa/pr21463.C: Likewise.
* g++.dg/tree-ssa/pr30738.C: Likewise.