https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91929
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2019-10-14
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
Ever confirmed|0 |1
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 47029
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47029&action=edit
patch for PRE
So GCC emits
.L40:
.loc 12 4459 13 is_stmt 0 view .LVU116
pxor %xmm0, %xmm0
addl $3, %ebx
movq 48(%rsp), %r13
cvtsi2sdl %r12d, %xmm0
call sin
.LVL39:
movsd %xmm0, 8(%rsp)
pxor %xmm0, %xmm0
cvtsi2sdl %ebx, %xmm0
movl %r12d, %ebx
call cos
.LVL40:
movsd 8(%rsp), %xmm2
movapd %xmm0, %xmm1
movapd %xmm2, %xmm0
call cabs
.LVL41:
.L23:
.LBB577:
.LBI577:
.loc 9 12 52 is_stmt 1 view .LVU117
where the surrounding locations are not exactly helpful (9 refers to t.C
while 12 refers to bits/stl_algo.h), but matches your observation.
GCC-wise I don't see a very good way to address this in an "exact" manner.
We'd somehow have to tell the debug consumer the stmts are from two
(multiple in general) different locations at the same time. Alternatively
we could pick one but the way PRE is implemented this could mean jumping
between one of the two (or many) alternatives for each stmt since consistency
here cannot be guaranteed.
The attached achieves that, it ends up accumulating the locations to the
end of the lambda.
(gdb) bt
#0 __cos_avx (x=3) at ../sysdeps/ieee754/dbl-64/s_sin.c:267
#1 0x0000000000400862 in std::cos<int> (__x=<optimized out>)
at
/home/space/rguenther/install/gcc-9.2/include/c++/9.2.0/bits/stl_algo.h:4459
#2 operator() (__closure=<optimized out>) at t.C:14
#3 std::generate_n<std::back_insert_iterator<std::vector<double> >, int,
main()::<lambda()> > (__n=100000, __gen=..., __first=...)
at
/home/space/rguenther/install/gcc-9.2/include/c++/9.2.0/bits/stl_algo.h:4460
#4 main () at t.C:16