public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/67167] New: cilkplus vectorization problems
@ 2015-08-10 7:56 marcin.krotkiewski at gmail dot com
2015-08-11 8:57 ` [Bug c/67167] " rguenth at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: marcin.krotkiewski at gmail dot com @ 2015-08-10 7:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67167
Bug ID: 67167
Summary: cilkplus vectorization problems
Product: gcc
Version: 5.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: marcin.krotkiewski at gmail dot com
Target Milestone: ---
I think there is a problem with vectorization of arithmetic operations in the
cilkplus implementation in gcc. I have inspected generated asm of the following
two implementations of vector addition (a = a + b). The code is compiled with
'gcc -O3 -mavx -ftree-vectorize -fopt-info-vec -fcilkplus test.c'.
// ICC compatibility - alignment hint
#ifdef __GNUC__
#define __assume_aligned(lvalueptr, align) lvalueptr = __builtin_assume_aligned
(lvalueptr, align)
#endif
#define RESTRICT __restrict__
typedef double Double;
void test(Double * RESTRICT a, Double * RESTRICT b, int size)
{
int i;
__assume_aligned(a, 64);
__assume_aligned(b, 64);
for(i=0; i<size; i++)
a[i] = a[i] + b[i];
}
void test_cilkplus1(Double * RESTRICT a, Double * RESTRICT b, int size)
{
__assume_aligned(a, 64);
__assume_aligned(b, 64);
a[0:size] = a[0:size] + b[0:size];
}
The first code (test) is vectorized as expected - here comes the ASM:
.L4:
vmovapd (%rdi,%r8), %ymm0
addl $1, %r9d
vaddpd (%rsi,%r8), %ymm0, %ymm0
vmovapd %ymm0, (%rdi,%r8)
addq $32, %r8
cmpl %r9d, %ecx
ja .L4
On the contrary, the second function (test_cilkplus1) is not vectorized:
.L21:
vmovsd (%rdi,%rax), %xmm0
movl %ecx, %r8d
addl $1, %ecx
vaddsd (%rsi,%rax), %xmm0, %xmm0
vmovsd %xmm0, (%rdi,%rax)
addq $8, %rax
cmpl %r8d, %edx
jg .L21
Now I have made sure that the compiler understands that there is no aliasing
(restrict) and that the vectors are aligned in memory. Clearly this is enough
for the standard implementation to produce a vectorized code, but not for the
CilkPlus array notation.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/67167] cilkplus vectorization problems
2015-08-10 7:56 [Bug c/67167] New: cilkplus vectorization problems marcin.krotkiewski at gmail dot com
@ 2015-08-11 8:57 ` rguenth at gcc dot gnu.org
2015-08-13 7:06 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-08-11 8:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67167
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-08-11
CC| |kyukhin at gcc dot gnu.org
Depends on| |66502
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
t.c:28:13: note: === get_loop_niters ===
t.c:28:13: note: not vectorized: number of iterations cannot be computed.
t.c:28:13: note: bad loop form.
t.c:22:6: note: vectorized 0 loops in function.
Which is probably because the loop has two IVs and a combined exit test:
<bb 5>:
# _32 = PHI <0(4), _21(6)>
# _33 = PHI <0(4), _22(6)>
...
_21 = _32 + 1;
_22 = _33 + 1;
_25 = size_9(D) > _22;
_23 = size_9(D) > _21;
_24 = _23 & _25;
if (_24 != 0)
goto <bb 6>;
else
goto <bb 7>;
related to PR66502 (proposed patch helps and makes the testcase vectorized,
but as noted in the PR regresses another case).
Not sure if this can be reasonably addressed in Cilk+ lowering as well?
(generate a single IV)
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66502
[Bug 66502] SCCVN can't handle PHIs optimistically optimally
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/67167] cilkplus vectorization problems
2015-08-10 7:56 [Bug c/67167] New: cilkplus vectorization problems marcin.krotkiewski at gmail dot com
2015-08-11 8:57 ` [Bug c/67167] " rguenth at gcc dot gnu.org
@ 2015-08-13 7:06 ` rguenth at gcc dot gnu.org
2015-08-13 7:10 ` rguenth at gcc dot gnu.org
2022-01-03 9:50 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-08-13 7:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67167
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Thu Aug 13 07:06:10 2015
New Revision: 226850
URL: https://gcc.gnu.org/viewcvs?rev=226850&root=gcc&view=rev
Log:
2015-08-13 Richard Biener <rguenther@suse.de>
PR tree-optimization/66502
PR tree-optimization/67167
* tree-ssa-sccvn.c (vn_phi_compute_hash): Do not include
backedge arguments.
(vn_phi_lookup): Adjust.
(vn_phi_insert): Likewise.
(visit_phi): Prefer to value-number to another PHI node
over value-numbering to a PHI argument.
(init_scc_vn): Mark DFS back edges.
* gcc.dg/tree-ssa/ssa-fre-46.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-46.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree-ssa-sccvn.c
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/67167] cilkplus vectorization problems
2015-08-10 7:56 [Bug c/67167] New: cilkplus vectorization problems marcin.krotkiewski at gmail dot com
2015-08-11 8:57 ` [Bug c/67167] " rguenth at gcc dot gnu.org
2015-08-13 7:06 ` rguenth at gcc dot gnu.org
@ 2015-08-13 7:10 ` rguenth at gcc dot gnu.org
2022-01-03 9:50 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-08-13 7:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67167
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/67167] cilkplus vectorization problems
2015-08-10 7:56 [Bug c/67167] New: cilkplus vectorization problems marcin.krotkiewski at gmail dot com
` (2 preceding siblings ...)
2015-08-13 7:10 ` rguenth at gcc dot gnu.org
@ 2022-01-03 9:50 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-03 9:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67167
Bug 67167 depends on bug 66502, which changed state.
Bug 66502 Summary: SCCVN can't handle PHIs optimistically optimally
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66502
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-01-03 9:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-10 7:56 [Bug c/67167] New: cilkplus vectorization problems marcin.krotkiewski at gmail dot com
2015-08-11 8:57 ` [Bug c/67167] " rguenth at gcc dot gnu.org
2015-08-13 7:06 ` rguenth at gcc dot gnu.org
2015-08-13 7:10 ` rguenth at gcc dot gnu.org
2022-01-03 9:50 ` rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).