c/94392 - only enable -ffinite-loops for C++
authorRichard Biener <rguenther@suse.de>
Thu, 2 Apr 2020 08:46:20 +0000 (10:46 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 2 Apr 2020 14:53:21 +0000 (16:53 +0200)
commit75efe9cb1f8938a713ce540dc3b27bc2afcd3fae
tree69f0c6905f576eeedd84101d3bfb66a72a2c4331
parent54af95767e887d63dc332731738e642536d87a48
c/94392 - only enable -ffinite-loops for C++

This does away with enabling -ffinite-loops at -O2+ for all languages
and instead enables it selectively for C++ only.

It also makes -ffinite-loops loop-private at CFG construction time
fixing correctness issues with inlining.

2020-04-02  Richard Biener  <rguenther@suse.de>

PR c/94392
* c-opts.c (c_common_post_options): Enable -ffinite-loops
for -O2 and C++11 or newer.

* common.opt (ffinite-loops): Initialize to zero.
* opts.c (default_options_table): Remove OPT_ffinite_loops
entry.
* cfgloop.h (loop::finite_p): New member.
* cfgloopmanip.c (copy_loop_info): Copy finite_p.
* ipa-icf-gimple.c (func_checker::compare_loops): Compare
finite_p.
* lto-streamer-in.c (input_cfg): Stream finite_p.
* lto-streamer-out.c (output_cfg): Likewise.
* tree-cfg.c (replace_loop_annotate): Initialize finite_p
from flag_finite_loops at CFG build time.
* tree-ssa-loop-niter.c (finite_loop_p): Check the loops
finite_p flag instead of flag_finite_loops.
* doc/invoke.texi (ffinite-loops): Adjust documentation of
default setting.

* gcc.dg/torture/pr94392.c: New testcase.
15 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-opts.c
gcc/cfgloop.h
gcc/cfgloopmanip.c
gcc/common.opt
gcc/doc/invoke.texi
gcc/ipa-icf-gimple.c
gcc/lto-streamer-in.c
gcc/lto-streamer-out.c
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr94392.c [new file with mode: 0644]
gcc/tree-cfg.c
gcc/tree-ssa-loop-niter.c