[Bug tree-optimization/99101] optimization bug with -ffinite-loops
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 15 09:43:20 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99101
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|og10 (devel/omp/gcc-10) |11.0
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Keywords| |wrong-code
Ever confirmed|0 |1
Last reconfirmed| |2021-02-15
Component|c++ |tree-optimization
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. But note that C++ requires forward progress and thus technically
the infinite loop invokes undefined behavior.
CDDCE2 does (with -fno-tree-sra to show at_eof_)
Assume loop 1 to be finite: it has an exit and -ffinite-loops is on.
Removing basic block 14
<bb 2> [local count: 1073741824]:
- comp_md_.at_eof_ = 0;
<bb 3> [local count: 108447916235]:
- # prephitmp_47 = PHI <1(2), 0(15)>
- # prephitmp_22 = PHI <0(2), prephitmp_27(15)>
- if (prephitmp_47 > 0)
- goto <bb 16>; [33.00%]
- else
- goto <bb 15>; [67.00%]
-
- <bb 16> [local count: 35787812164]:
-
- <bb 4> [local count: 53412352861]:
- # i_9 = PHI <i_8(14), 0(16)>
- # prephitmp_11 = PHI <pretmp_2(14), prephitmp_22(16)>
- if (prephitmp_11 != 0)
- goto <bb 12>; [34.00%]
- else
- goto <bb 5>; [66.00%]
-
- <bb 5> [local count: 11633210387]:
- comp_md_.at_eof_ = 1;
_14 = std::basic_ostream<char>::operator<< (&cout, 1);
_15 = _14->_vptr.basic_ostream;
_16 = MEM[(long int *)_15 + -24B];
@@ -99,28 +88,12 @@
_43 = OBJ_TYPE_REF(_37;(const struct ctype)_23->6) (_23, 10);
_10 = (int) _43;
- <bb 11> [local count: 11628557050]:
+ <bb 11> [local count: 53407699675]:
# prephitmp_24 = PHI <_13(8), 10(9), _10(10)>
_21 = std::basic_ostream<char>::put (_14, prephitmp_24);
std::basic_ostream<char>::flush (_21);
- <bb 12> [local count: 53407699675]:
- i_8 = i_9 + 1;
- if (i_8 < prephitmp_47)
- goto <bb 14>; [33.00%]
- else
- goto <bb 13>; [67.00%]
-
- <bb 13> [local count: 35783158878]:
- pretmp_25 = comp_md_.at_eof_;
- goto <bb 15>; [100.00%]
-
- <bb 14> [local count: 17624540797]:
- pretmp_2 = comp_md_.at_eof_;
- goto <bb 4>; [100.00%]
-
<bb 15> [local count: 108443262898]:
- # prephitmp_27 = PHI <pretmp_25(13), prephitmp_22(3)>
goto <bb 3>; [100.00%]
}
so the question would be why the std::cout << 1 call doesn't add its
control dependence as necessary here. Hmm, and the reason is we have
BB 5 only control dependent on itself.
And I have a hunch that this boils down to post dominators being
"wrong" here because of the missing edges to exit. Indeed if
connecting infinite loops to exit in CD-DCE the bug is fixed.
More information about the Gcc-bugs
mailing list