[Bug tree-optimization/53090] suboptimal ivopt

2017-08-08 Thread amker at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53090

amker at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from amker at gcc dot gnu.org ---
Hmm, It's not mentioned at which optimization level the original bug was
reported.  I suspect O2 because vect_perm instruction is needed after
vectorization.  So current status is:
After ivopt rewriting, we generate below 8 instructions loop at O2
.L14:
movl(%r14,%rax,4), %ecx
movl(%r14,%rdx,4), %esi
movl%esi, (%r14,%rax,4)
movl%ecx, (%r14,%rdx,4)
addq$1, %rax
subq$1, %rdx
cmpl%eax, %edx
jg  .L14

It's better than what was reported.

at O3:
.L14:
movdqu  (%rsi,%rdx), %xmm2
movdqa  (%r12,%rax), %xmm0
pshufd  $27, %xmm2, %xmm1
pshufd  $27, %xmm0, %xmm0
movaps  %xmm1, (%r12,%rax)
addq$16, %rax
movups  %xmm0, (%rsi,%rdx)
subq$16, %rdx
cmpq%rax, %rdi
jne .L14

Consider this fixed.

[Bug tree-optimization/53090] suboptimal ivopt

2017-05-11 Thread amker at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53090

--- Comment #9 from amker at gcc dot gnu.org ---
Author: amker
Date: Thu May 11 09:50:15 2017
New Revision: 247893

URL: https://gcc.gnu.org/viewcvs?rev=247893&root=gcc&view=rev
Log:
PR tree-optimization/53090
* tree-ssa-loop-ivopts.c (enum comp_iv_rewrite): New enum value
COMP_IV_EXPR_2.
(extract_cond_operands): Detect condition with IV on both sides
and return COMP_IV_EXPR_2.
(find_interesting_uses_cond): Add iv_use for both IVs in condition.
(rewrite_use_compare): Simplify by removing call to function
extract_cond_operands.

Modified:
trunk/gcc/ChangeLog
trunk/gcc/tree-ssa-loop-ivopts.c