* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
@ 2011-01-27 7:08 ` hjl.tools at gmail dot com
2011-01-27 11:51 ` rguenth at gcc dot gnu.org
` (26 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: hjl.tools at gmail dot com @ 2011-01-27 7:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |i686
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.01.27 05:41:05
CC| |bernds at gcc dot gnu.org,
| |hjl.tools at gmail dot com
Host|Linux x86-64 |
Target Milestone|--- |4.6.0
Ever Confirmed|0 |1
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2011-01-27 05:41:05 UTC ---
It is caused by revision 162418:
http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg00772.html
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
2011-01-27 7:08 ` [Bug rtl-optimization/47477] " hjl.tools at gmail dot com
@ 2011-01-27 11:51 ` rguenth at gcc dot gnu.org
2011-01-27 17:34 ` jakub at gcc dot gnu.org
` (25 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-27 11:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|i686 |i?86-*-*
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-27 11:22:39 UTC ---
The specific pattern looks easy to catch in a peephole2 or machine dependent
reorg (for destructive arith archs).
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
2011-01-27 7:08 ` [Bug rtl-optimization/47477] " hjl.tools at gmail dot com
2011-01-27 11:51 ` rguenth at gcc dot gnu.org
@ 2011-01-27 17:34 ` jakub at gcc dot gnu.org
2011-01-27 17:58 ` jakub at gcc dot gnu.org
` (24 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-27 17:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-27 17:21:04 UTC ---
Not so easily, addsi3_cc is quite specialized pattern and if we add peepholes
to help with reg1 = reg1 op reg2; reg2 = reg1 [reg1 DEAD];
I think we'd add it only for a couple of most common arithmetics ops.
Wonder whether the splitters couldn't be smarter here, when splitting a
doubleword addition see that we only care about a SImode subreg thereof.
Or, if lower-subreg.c could do something about it, optimize
(insn 10 9 11 2 (parallel [
(set (reg:DI 74)
(plus:DI (reg:DI 71)
(reg:DI 73)))
(clobber (reg:CC 17 flags))
]) pr47477.c:4 243 {*adddi3_doubleword}
(nil))
(insn 11 10 12 2 (set (reg:SI 70)
(subreg:SI (reg:DI 74) 0)) pr47477.c:5 64 {*movsi_internal}
(nil))
into just SImode addition.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (2 preceding siblings ...)
2011-01-27 17:34 ` jakub at gcc dot gnu.org
@ 2011-01-27 17:58 ` jakub at gcc dot gnu.org
2011-01-27 19:43 ` tony.poppleton at gmail dot com
` (23 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-27 17:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rth at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-27 17:45:33 UTC ---
Alternatively, this narrowing of > word mode operations could as well be done
during tree optimizations. I think the FE is the only place which performs
them,
as can be seen if you modify your testcase to do:
void *
add (void *a, void *b)
{
return (void *)(__INTPTR_TYPE__) ((long long)(__INTPTR_TYPE__) a + ((long
long)(__INTPTR_TYPE__) b & ~1L));
}
instead of
void *
add (void *a, void *b)
{
long long tmp = (long long)(__INTPTR_TYPE__) a + ((long
long)(__INTPTR_TYPE__) b & ~1L);
return (void *)(__INTPTR_TYPE__) tmp;
}
But unfortunately we have nothing which performs this later on (gimple-fold?).
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (3 preceding siblings ...)
2011-01-27 17:58 ` jakub at gcc dot gnu.org
@ 2011-01-27 19:43 ` tony.poppleton at gmail dot com
2011-01-28 11:31 ` rguenth at gcc dot gnu.org
` (22 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: tony.poppleton at gmail dot com @ 2011-01-27 19:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #5 from Tony Poppleton <tony.poppleton at gmail dot com> 2011-01-27 17:58:12 UTC ---
The modified testcase in comment #4 also fixes the original bug with redundent
push/pop of BX (as described in PR35926), so fixing this during tree
optimizations would be good.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (4 preceding siblings ...)
2011-01-27 19:43 ` tony.poppleton at gmail dot com
@ 2011-01-28 11:31 ` rguenth at gcc dot gnu.org
2011-01-29 20:37 ` jakub at gcc dot gnu.org
` (21 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-28 11:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-28 11:04:19 UTC ---
(In reply to comment #4)
> Alternatively, this narrowing of > word mode operations could as well be done
> during tree optimizations. I think the FE is the only place which performs
> them,
> as can be seen if you modify your testcase to do:
> void *
> add (void *a, void *b)
> {
> return (void *)(__INTPTR_TYPE__) ((long long)(__INTPTR_TYPE__) a + ((long
> long)(__INTPTR_TYPE__) b & ~1L));
> }
> instead of
> void *
> add (void *a, void *b)
> {
> long long tmp = (long long)(__INTPTR_TYPE__) a + ((long
> long)(__INTPTR_TYPE__) b & ~1L);
> return (void *)(__INTPTR_TYPE__) tmp;
> }
>
> But unfortunately we have nothing which performs this later on (gimple-fold?).
As it needs to combine several statements tree forwprop is our current
place to deal with this (as our "tree combiner"). Similar to the
new associate_plusminus code we should have combiners (not re-using fold)
to combine conversions.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (5 preceding siblings ...)
2011-01-28 11:31 ` rguenth at gcc dot gnu.org
@ 2011-01-29 20:37 ` jakub at gcc dot gnu.org
2011-02-08 14:40 ` rguenth at gcc dot gnu.org
` (20 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-29 20:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-29 19:40:25 UTC ---
forwprop is a forward walk, for this kind of optimization we want to walk
backwards, from the narrowing integer conversion to the operations and whenever
we change some operation see if we can change the def_stmts of its operands
too.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (6 preceding siblings ...)
2011-01-29 20:37 ` jakub at gcc dot gnu.org
@ 2011-02-08 14:40 ` rguenth at gcc dot gnu.org
2011-02-08 14:41 ` rguenth at gcc dot gnu.org
` (19 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-08 14:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (7 preceding siblings ...)
2011-02-08 14:40 ` rguenth at gcc dot gnu.org
@ 2011-02-08 14:41 ` rguenth at gcc dot gnu.org
2011-02-21 16:19 ` jakub at gcc dot gnu.org
` (18 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-02-08 14:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-02-08 14:39:25 UTC ---
(In reply to comment #7)
> forwprop is a forward walk, for this kind of optimization we want to walk
> backwards, from the narrowing integer conversion to the operations and whenever
> we change some operation see if we can change the def_stmts of its operands
> too.
forwprop does both, walking forward and backward today. It's just misnamed now
;)
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (8 preceding siblings ...)
2011-02-08 14:41 ` rguenth at gcc dot gnu.org
@ 2011-02-21 16:19 ` jakub at gcc dot gnu.org
2012-01-02 11:36 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
` (17 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-02-21 16:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.6.0 |4.7.0
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6/4.7/4.8 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (9 preceding siblings ...)
2011-02-21 16:19 ` jakub at gcc dot gnu.org
@ 2012-01-02 11:36 ` jakub at gcc dot gnu.org
2012-03-06 12:48 ` jakub at gcc dot gnu.org
` (16 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-01-02 11:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot |jakub at gcc dot gnu.org
|gnu.org |
Target Milestone|4.7.0 |4.8.0
Summary|[4.6/4.7 regression] |[4.6/4.7/4.8 regression]
|Sub-optimal mov at end of |Sub-optimal mov at end of
|method |method
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-01-02 11:36:32 UTC ---
Postponing for 4.8, as agreed by Richard this is stage1 material and
unfortunately has been forgotten during 4.7 stage1. From quick glance at it,
we want to reimplement get_unwidened and the narrowing integer conversion part
of convert_to_integer on GIMPLE, must likely in forwprop.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6/4.7/4.8 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (10 preceding siblings ...)
2012-01-02 11:36 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8 " jakub at gcc dot gnu.org
@ 2012-03-06 12:48 ` jakub at gcc dot gnu.org
2012-11-30 16:27 ` jakub at gcc dot gnu.org
` (15 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-06 12:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-06 12:48:30 UTC ---
Related to PR45397.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6/4.7/4.8 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (11 preceding siblings ...)
2012-03-06 12:48 ` jakub at gcc dot gnu.org
@ 2012-11-30 16:27 ` jakub at gcc dot gnu.org
2013-03-22 14:46 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8/4.9 " jakub at gcc dot gnu.org
` (14 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-11-30 16:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ktietz at gcc dot gnu.org
AssignedTo|jakub at gcc dot gnu.org |unassigned at gcc dot
| |gnu.org
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-11-30 16:24:54 UTC ---
Kai has some patch for this that missed the 4.8 deadline, hopefully it will be
posted soon for discussions and review.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6/4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (12 preceding siblings ...)
2012-11-30 16:27 ` jakub at gcc dot gnu.org
@ 2013-03-22 14:46 ` jakub at gcc dot gnu.org
2013-04-10 1:44 ` tony.poppleton at gmail dot com
` (13 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-03-22 14:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.0 |4.8.1
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-22 14:44:54 UTC ---
GCC 4.8.0 is being released, adjusting target milestone.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.6/4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (13 preceding siblings ...)
2013-03-22 14:46 ` [Bug rtl-optimization/47477] [4.6/4.7/4.8/4.9 " jakub at gcc dot gnu.org
@ 2013-04-10 1:44 ` tony.poppleton at gmail dot com
2013-05-31 11:03 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
` (12 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: tony.poppleton at gmail dot com @ 2013-04-10 1:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #13 from Tony Poppleton <tony.poppleton at gmail dot com> 2013-04-10 01:44:18 UTC ---
The test case appears to be fixed in GCC 4.8.0, compiling with just -S and -O3,
the asm
output is now a much simpler:
.file "test.c"
.text
.p2align 4,,15
.globl add
.type add, @function
add:
.LFB0:
.cfi_startproc
andq $-2, %rsi
leaq (%rdi,%rsi), %rax
ret
.cfi_endproc
.LFE0:
.size add, .-add
.ident "GCC: (GNU) 4.8.0 20130316 (Red Hat 4.8.0-0.17)"
.section .note.GNU-stack,"",@progbits
I don't know if other test cases would reproduce the original bug however.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (14 preceding siblings ...)
2013-04-10 1:44 ` tony.poppleton at gmail dot com
@ 2013-05-31 11:03 ` jakub at gcc dot gnu.org
2013-10-16 9:49 ` jakub at gcc dot gnu.org
` (11 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-05-31 11:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.1 |4.8.2
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.1 has been released.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (15 preceding siblings ...)
2013-05-31 11:03 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9 " jakub at gcc dot gnu.org
@ 2013-10-16 9:49 ` jakub at gcc dot gnu.org
2013-10-22 13:40 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-16 9:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.2 |4.8.3
--- Comment #15 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.2 has been released.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (16 preceding siblings ...)
2013-10-16 9:49 ` jakub at gcc dot gnu.org
@ 2013-10-22 13:40 ` jakub at gcc dot gnu.org
2013-10-22 14:18 ` ktietz at gcc dot gnu.org
` (9 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-22 13:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Another testcase:
short a[1024], b[1024];
void
foo (void)
{
int i;
for (i = 0; i < 1024; i++)
{
short c = (char) a[i] + 5;
long long d = (long long) b[i] + 12;
a[i] = c + d;
}
}
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (17 preceding siblings ...)
2013-10-22 13:40 ` jakub at gcc dot gnu.org
@ 2013-10-22 14:18 ` ktietz at gcc dot gnu.org
2013-10-22 14:56 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: ktietz at gcc dot gnu.org @ 2013-10-22 14:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #17 from Kai Tietz <ktietz at gcc dot gnu.org> ---
What optimization you expect here? I see by the new type-demotion pass some
changes in optimized tree-output:
foo ()
{
int i;
short int _4;
char _5;
unsigned short _6;
unsigned short _8;
short int _9;
unsigned short _10;
unsigned short _11;
short int _12;
sizetype _25;
<bb 2>:
goto <bb 4>;
<bb 3>:
<bb 4>:
# i_17 = PHI <i_14(3), 0(2)>
_25 = (sizetype) i_17;
_4 = MEM[symbol: a, index: _25, step: 2, offset: 0B];
_5 = (char) _4;
_6 = (unsigned short) _5;
_9 = MEM[symbol: b, index: _25, step: 2, offset: 0B];
_8 = (unsigned short) _9;
_10 = _8 + 17;
_11 = _10 + _6;
_12 = (short int) _11;
MEM[symbol: a, index: _25, step: 2, offset: 0B] = _12;
i_14 = i_17 + 1;
if (i_14 != 1024)
goto <bb 3>;
else
goto <bb 5>;
<bb 5>:
return;
}
what then gets simplified to the following assembler on IA32:
_foo:
xorl %eax, %eax
.p2align 4,,10
L2:
movsbw _a(%eax,%eax), %dx
movzwl _b(%eax,%eax), %ecx
leal 17(%ecx,%edx), %edx
movw %dx, _a(%eax,%eax)
addl $1, %eax
cmpl $1024, %eax
jne L2
rep ret
The same assembler gets produced for my with all compilers back to 4.6.0, just
tree-optimization output differs.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.7/4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (18 preceding siblings ...)
2013-10-22 14:18 ` ktietz at gcc dot gnu.org
@ 2013-10-22 14:56 ` jakub at gcc dot gnu.org
2014-05-22 9:07 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
` (7 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-10-22 14:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Kai Tietz from comment #17)
> What optimization you expect here? I see by the new type-demotion pass some
> changes in optimized tree-output:
This one is for vectorization, try it with -O3 -mavx2 and look what vectorized
loop we get. With type demotion and promotion for the vectorized loops
(perhaps only for that and not for the scalar loops), you could get similar
vectorization to say:
short a[1024], b[1024];
void
foo (void)
{
int i;
for (i = 0; i < 1024; i++)
{
unsigned short c = ((short)(a[i] << 8) >> 8) + 5U;
unsigned short d = b[i] + 12U;
a[i] = c + d;
}
}
though even in this case I still couldn't achieve the sign extension to be
actually performed as 16-bit left + right (signed) shift, while I guess that
would lead to even better code.
Or look at how we vectorize:
short a[1024], b[1024];
void
foo (void)
{
int i;
for (i = 0; i < 1024; i++)
{
unsigned char e = a[i];
short c = e + 5;
long long d = (long long) b[i] + 12;
a[i] = c + d;
}
}
(note, here forwprop pass already performs type promotion, instead of
converting a[i] to unsigned char and back to short, it computes a[i] & 255 in
short mode) and how we could instead with type demotions:
short a[1024], b[1024];
void
foo (void)
{
int i;
for (i = 0; i < 1024; i++)
{
unsigned short c = (a[i] & 0xff) + 5U;
unsigned short d = b[i] + 12U;
a[i] = c + d;
}
}
These are all admittedly artificial testcases, but I've seen tons of loops
where multiple types were vectorized and I think in some portion of those loops
we could either use just a single type size, or at least decrease the number of
conversions and different type sizes in the vectorized loops.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.7/4.8/4.9/4.10 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (19 preceding siblings ...)
2013-10-22 14:56 ` jakub at gcc dot gnu.org
@ 2014-05-22 9:07 ` rguenth at gcc dot gnu.org
2014-12-19 13:40 ` [Bug rtl-optimization/47477] [4.8/4.9/5 " jakub at gcc dot gnu.org
` (6 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-05-22 9:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.3 |4.8.4
--- Comment #19 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 4.8.3 is being released, adjusting target milestone.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.8/4.9/5 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (20 preceding siblings ...)
2014-05-22 9:07 ` [Bug rtl-optimization/47477] [4.7/4.8/4.9/4.10 " rguenth at gcc dot gnu.org
@ 2014-12-19 13:40 ` jakub at gcc dot gnu.org
2015-02-13 20:18 ` law at gcc dot gnu.org
` (5 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.4 |4.8.5
--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.8/4.9/5 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (21 preceding siblings ...)
2014-12-19 13:40 ` [Bug rtl-optimization/47477] [4.8/4.9/5 " jakub at gcc dot gnu.org
@ 2015-02-13 20:18 ` law at gcc dot gnu.org
2015-02-13 20:20 ` [Bug rtl-optimization/47477] [4.8/4.9 " law at redhat dot com
` (4 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: law at gcc dot gnu.org @ 2015-02-13 20:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #21 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Author: law
Date: Fri Feb 13 20:17:55 2015
New Revision: 220695
URL: https://gcc.gnu.org/viewcvs?rev=220695&root=gcc&view=rev
Log:
PR rtl-optimization/47477
* match.pd (convert (plus/minus (convert @0) (convert @1): New
simplifier to narrow arithmetic.
PR rtl-optimization/47477
* gcc.dg/tree-ssa/pr47477.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr47477.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/match.pd
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (22 preceding siblings ...)
2015-02-13 20:18 ` law at gcc dot gnu.org
@ 2015-02-13 20:20 ` law at redhat dot com
2015-02-17 5:22 ` law at redhat dot com
` (3 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: law at redhat dot com @ 2015-02-13 20:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jeffrey A. Law <law at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |law at redhat dot com
Summary|[4.8/4.9/5 regression] |[4.8/4.9 regression]
|Sub-optimal mov at end of |Sub-optimal mov at end of
|method |method
--- Comment #22 from Jeffrey A. Law <law at redhat dot com> ---
Patch to match.pd fixes the regresssion on the trunk. Will be opening a
separate BZ for the missed optimizations.
Given the fix depends on the match.pd functionality, I don't see any chance
we'll ever backport this to the release branches.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (23 preceding siblings ...)
2015-02-13 20:20 ` [Bug rtl-optimization/47477] [4.8/4.9 " law at redhat dot com
@ 2015-02-17 5:22 ` law at redhat dot com
2015-06-23 8:20 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
27 siblings, 0 replies; 29+ messages in thread
From: law at redhat dot com @ 2015-02-17 5:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #23 from Jeffrey A. Law <law at redhat dot com> ---
Additional tests were extracted into BZ65084. This BZ is just for tracking the
regression for testcase in c#0.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.8/4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (24 preceding siblings ...)
2015-02-17 5:22 ` law at redhat dot com
@ 2015-06-23 8:20 ` rguenth at gcc dot gnu.org
2015-06-26 20:13 ` [Bug rtl-optimization/47477] [4.9 " jakub at gcc dot gnu.org
2015-06-26 20:35 ` jakub at gcc dot gnu.org
27 siblings, 0 replies; 29+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-23 8:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.8.5 |4.9.3
--- Comment #24 from Richard Biener <rguenth at gcc dot gnu.org> ---
The gcc-4_8-branch is being closed, re-targeting regressions to 4.9.3.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (25 preceding siblings ...)
2015-06-23 8:20 ` rguenth at gcc dot gnu.org
@ 2015-06-26 20:13 ` jakub at gcc dot gnu.org
2015-06-26 20:35 ` jakub at gcc dot gnu.org
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-06-26 20:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
--- Comment #25 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.3 has been released.
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Bug rtl-optimization/47477] [4.9 regression] Sub-optimal mov at end of method
2011-01-26 16:54 [Bug rtl-optimization/47477] New: [4.6 regression] Sub-optimal mov at end of method tony.poppleton at gmail dot com
` (26 preceding siblings ...)
2015-06-26 20:13 ` [Bug rtl-optimization/47477] [4.9 " jakub at gcc dot gnu.org
@ 2015-06-26 20:35 ` jakub at gcc dot gnu.org
27 siblings, 0 replies; 29+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-06-26 20:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47477
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.9.3 |4.9.4
^ permalink raw reply [flat|nested] 29+ messages in thread