The following makes the last DCE pass CD-DCE and in turn the
last CD-DCE pass a DCE one. That ensues we remove empty loops
that become empty between the two. I've also moved the tail-call
pass after DCE since DCE can only improve things here.
The two testcases were the only ones scanning cddce3 so I've
changed them to scan the dce7 pass that's now in this place.
The testcases scanning dce7 also work when that's in the earlier
position.
PR tree-optimization/84646
* tree-ssa-dce.cc (pass_dce::set_pass_param): Add param
wheter to run update-address-taken.
(pass_dce::execute): Honor it.
* passes.def: Exchange last DCE and CD-DCE invocations.
Swap pass_tail_calls and the last DCE.
* g++.dg/tree-ssa/pr106922.C: Continue to scan earlier DCE dump.
* gcc.dg/tree-ssa/
20030808-1.c: Likewise.
NEXT_PASS (pass_ccp, true /* nonzero_p */);
NEXT_PASS (pass_warn_restrict);
NEXT_PASS (pass_dse);
- NEXT_PASS (pass_cd_dce, true /* update_address_taken_p */);
- /* After late CD DCE we rewrite no longer addressed locals into SSA
+ NEXT_PASS (pass_dce, true /* update_address_taken_p */);
+ /* After late DCE we rewrite no longer addressed locals into SSA
form if possible. */
NEXT_PASS (pass_forwprop);
NEXT_PASS (pass_sink_code, true /* unsplit edges */);
NEXT_PASS (pass_fold_builtins);
NEXT_PASS (pass_optimize_widening_mul);
NEXT_PASS (pass_store_merging);
- NEXT_PASS (pass_tail_calls);
/* If DCE is not run before checking for uninitialized uses,
we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c).
However, this also causes us to misdiagnose cases that should be
real warnings (e.g., testsuite/gcc.dg/pr18501.c). */
- NEXT_PASS (pass_dce);
+ NEXT_PASS (pass_cd_dce, false /* update_address_taken_p */);
+ NEXT_PASS (pass_tail_calls);
/* Split critical edges before late uninit warning to reduce the
number of false positives from it. */
NEXT_PASS (pass_split_crit_edges);
// { dg-require-effective-target c++20 }
-// { dg-options "-O2 -fdump-tree-cddce3" }
+// { dg-options "-O2 -fdump-tree-dce7" }
template <typename> struct __new_allocator {
void deallocate(int *, int) { operator delete(0); }
}
}
-// { dg-final { scan-tree-dump-not "m_initialized" "cddce3" } }
+// { dg-final { scan-tree-dump-not "m_initialized" "dce7" } }
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-cddce3" } */
+/* { dg-options "-O1 -fdump-tree-dce7" } */
extern void abort (void);
/* There should be no loads of ->code. If any exist, then we failed to
optimize away all the IF statements and the statements feeding
their conditions. */
-/* { dg-final { scan-tree-dump-times "->code" 0 "cddce3"} } */
+/* { dg-final { scan-tree-dump-times "->code" 0 "dce7"} } */
/* There should be no IF statements. */
-/* { dg-final { scan-tree-dump-times "if " 0 "cddce3"} } */
+/* { dg-final { scan-tree-dump-times "if " 0 "dce7"} } */
{
public:
pass_dce (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_dce, ctxt)
+ : gimple_opt_pass (pass_data_dce, ctxt), update_address_taken_p (false)
{}
/* opt_pass methods: */
opt_pass * clone () final override { return new pass_dce (m_ctxt); }
+ void set_pass_param (unsigned n, bool param) final override
+ {
+ gcc_assert (n == 0);
+ update_address_taken_p = param;
+ }
bool gate (function *) final override { return flag_tree_dce != 0; }
- unsigned int execute (function *) final override { return tree_ssa_dce (); }
+ unsigned int execute (function *) final override
+ {
+ return (tree_ssa_dce ()
+ | (update_address_taken_p ? TODO_update_address_taken : 0));
+ }
+private:
+ bool update_address_taken_p;
}; // class pass_dce
} // anon namespace