This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/84151] [6/7/8 Regression] g++ generates two identical loads in a volatile-qualified member function.
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 01 Feb 2018 09:42:58 +0000
- Subject: [Bug c++/84151] [6/7/8 Regression] g++ generates two identical loads in a volatile-qualified member function.
- Auto-submitted: auto-generated
- References: <bug-84151-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84151
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-02-01
Target Milestone|--- |6.5
Summary|[4.9/5/6/7 Regression] g++ |[6/7/8 Regression] g++
|generates two identical |generates two identical
|loads in a |loads in a
|volatile-qualified member |volatile-qualified member
|function. |function.
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The C++ FE generates
;; Function int A::foo() volatile (null)
;; enabled by -tree-original
{
int v;
int v;
<<cleanup_point <<< Unknown tree: expr_stmt
(void) (v = (int) ((volatile struct A *) this)->c) >>>>>;
<<cleanup_point return <retval> = *(volatile struct A *) this;, *A::bar ((int
&) &v);>>;
}
which results in
int A::foo() volatile (volatile struct A * const this)
{
int v;
struct A vol.0;
int _1;
int & _2;
int _8;
<bb 2> [0.00%]:
_1 ={v} this_4(D)->c;
v = _1;
vol.0 ={v} *this_4(D);
_2 = A::bar (&v);
_8 = *_2;
v ={v} {CLOBBER};
return _8;
I'm not sure how the behavior of a volatile this is specified but this
unused copy of *this looks unwarranted.