public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
@ 2012-10-13 10:18 zsojka at seznam dot cz
2012-10-13 10:39 ` [Bug rtl-optimization/54919] " steven at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: zsojka at seznam dot cz @ 2012-10-13 10:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Bug #: 54919
Summary: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c
FAILs with -fvariable-expansion-in-unroller
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: zsojka@seznam.cz
Created attachment 28439
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28439
preprocessed source
Output:
$ gcc -O2 -ffast-math -funroll-loops -fvariable-expansion-in-unroller
testcase.c
$ ./a.out
Aborted
What happens is that foo() returns -63 instead of -64.
.L15:
movapd xmm0, xmm2 # d, tmp71
sub eax, 8 # D.1761,
subsd xmm0, xmm1 # d, tmp69
subsd xmm0, xmm1 # d, tmp69
subsd xmm0, xmm1 # d, tmp69
1==> movapd xmm2, xmm0 # tmp71, d
2==> subsd xmm2, xmm1 # tmp71, tmp69
jne .L15 #,
3==> addsd xmm0, xmm2 # d, tmp71
cvttsd2si edx, xmm0 # D.1762, d
In each loop, 4 is subtracted, and finally, the sum is multiplied by 2 at (3).
The problem is that when (3) is executed, xmm2==-32 and xmm0==-31 ; so the
final sum is -63.
If (1) and (2) are swapped (and (2) uses xmm0 instead of xmm2), the code works
fine:
.L15:
movapd xmm0, xmm2 # d, tmp71
sub eax, 8 # D.1761,
subsd xmm0, xmm1 # d, tmp69
subsd xmm0, xmm1 # d, tmp69
subsd xmm0, xmm1 # d, tmp69
2==> subsd xmm0, xmm1 # tmp71, tmp69
1==> movapd xmm2, xmm0 # tmp71, d
jne .L15 #,
3==> addsd xmm0, xmm2 # d, tmp71
cvttsd2si edx, xmm0 # D.1762, d
Note foo() is inlined into main(), so the change has to be done in main() (or
the noinline attribute has to be added).
Tested revisions:
r192420 - fail
4.7 r191640 - fail
4.6 r191640 - fail
4.5 r191640 - fail
4.4 r191640 - OK
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
@ 2012-10-13 10:39 ` steven at gcc dot gnu.org
2012-10-13 16:38 ` steven at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-13 10:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-10-13
AssignedTo|unassigned at gcc dot |steven at gcc dot gnu.org
|gnu.org |
Ever Confirmed|0 |1
--- Comment #1 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-13 10:38:51 UTC ---
I'll have a look.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
2012-10-13 10:39 ` [Bug rtl-optimization/54919] " steven at gcc dot gnu.org
@ 2012-10-13 16:38 ` steven at gcc dot gnu.org
2012-10-13 18:06 ` hubicka at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-13 16:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
--- Comment #2 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-13 16:38:14 UTC ---
At the ".178r.loop2_invariant" dump:
5 r61:SI=0x40 # 64
6 r62:DF=[`*.LC0'] # 0.0
34 r68:DF=[`*.LC1'] # 1.0e+0
L16:
11 r62:DF=r62:DF-r68:DF
12 {r61:SI=r61:SI-0x1;clobber flags:CC;}
13 flags:CCZ=cmp(r61:SI,0)
14 pc={(flags:CCZ==0)?L19:pc}
# {implicit: pc=L16}
L19:
21 r67:SI=fix(r62:DF)
26 ax:SI=r67:SI
29 use ax:SI
Clearly the above loop iterates 64 times. But in the next pass
(".180r.loop2_unroll") the iterations estimate is not 64:
;; *** Considering loop 1 for complete peeling ***
;; Considering peeling once rolling loop
...
Loop 1 is simple:
simple exit 3 -> 5
number of iterations: (const_int 63 [0x3f])
upper bound: 63
realistic bound: 63
;; Unable to prove that the loop rolls exactly once
;; Considering peeling completely
;; Not peeling loop completely, rolls too much (63 iterations > 16 [maximum
peelings])
;; *** Considering loop 1 ***
;; Considering unrolling loop with constant number of iterations
;; max_unroll 8 (8 copies, initial 8).
;; Decided to unroll the constant times rolling loop, 7 times.
But with the wrong iteration estimate, the unrolled loop size is wrong.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
2012-10-13 10:39 ` [Bug rtl-optimization/54919] " steven at gcc dot gnu.org
2012-10-13 16:38 ` steven at gcc dot gnu.org
@ 2012-10-13 18:06 ` hubicka at gcc dot gnu.org
2012-10-13 21:51 ` steven at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-10-13 18:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org
--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-10-13 18:06:29 UTC ---
I think the dump is right. Number of iterations as defined by loop
infrastructure is number of execution of loopback edges. For loop after loop
header copying has one iteration fewer than one would naturaly assume.
The dump seems right - the constant unrolling unrolls 8x that it reports as 7
peelings (that means "produce 7 extra copies of body")
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (2 preceding siblings ...)
2012-10-13 18:06 ` hubicka at gcc dot gnu.org
@ 2012-10-13 21:51 ` steven at gcc dot gnu.org
2012-10-14 19:29 ` steven at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-13 21:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
--- Comment #4 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-13 21:51:15 UTC ---
Created attachment 28442
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28442
Perform replacement in REG_EQUAL notes too
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (3 preceding siblings ...)
2012-10-13 21:51 ` steven at gcc dot gnu.org
@ 2012-10-14 19:29 ` steven at gcc dot gnu.org
2012-10-14 20:31 ` [Bug rtl-optimization/54919] [4.6/4.7 " steven at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-14 19:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
--- Comment #5 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-14 19:29:22 UTC ---
Author: steven
Date: Sun Oct 14 19:29:18 2012
New Revision: 192439
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192439
Log:
gcc/
PR rtl-optimization/54919
* loop-unroll.c (struct var_to_expand): Remove accum_pos field.
(analyze_insn_to_expand_var): Do not record accum_pos.
(expand_var_during_unrolling): Use validate_replace_rtx_group to
perform replacement of all references to SET_DEST (set) with the
new register, including references in REG_EQUAL notes.
(insert_var_expansion_initialization): Insert initializatio insns
at the bottom of the pre-header of the loop.
testsuite/
PR rtl-optimization/54919
* gcc.dg/pr54919.c: New testcase.
Added:
trunk/gcc/testsuite/gcc.dg/pr54919.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/loop-unroll.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (4 preceding siblings ...)
2012-10-14 19:29 ` steven at gcc dot gnu.org
@ 2012-10-14 20:31 ` steven at gcc dot gnu.org
2012-10-14 20:32 ` steven at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-14 20:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.8.0
AssignedTo|steven at gcc dot gnu.org |unassigned at gcc dot
| |gnu.org
Summary|[4.6/4.7/4.8 Regression] |[4.6/4.7 Regression]
|gcc.dg/torture/pr54877.c |gcc.dg/torture/pr54877.c
|FAILs with |FAILs with
|-fvariable-expansion-in-unr |-fvariable-expansion-in-unr
|oller |oller
Known to fail|4.8.0 |
--- Comment #6 from Steven Bosscher <steven at gcc dot gnu.org> 2012-10-14 20:30:42 UTC ---
Fixed on the trunk, see r192439.
I have no plans to work on back-ports of my patch for the release
branches, so unassigning...
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (5 preceding siblings ...)
2012-10-14 20:31 ` [Bug rtl-optimization/54919] [4.6/4.7 " steven at gcc dot gnu.org
@ 2012-10-14 20:32 ` steven at gcc dot gnu.org
2013-04-03 9:45 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu.org @ 2012-10-14 20:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
Target Milestone|--- |4.6.4
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.6/4.7 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (6 preceding siblings ...)
2012-10-14 20:32 ` steven at gcc dot gnu.org
@ 2013-04-03 9:45 ` rguenth at gcc dot gnu.org
2013-04-12 15:18 ` [Bug rtl-optimization/54919] [4.7 " jakub at gcc dot gnu.org
2014-06-12 13:18 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-03 9:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.7 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (7 preceding siblings ...)
2013-04-03 9:45 ` rguenth at gcc dot gnu.org
@ 2013-04-12 15:18 ` jakub at gcc dot gnu.org
2014-06-12 13:18 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-12 15:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.6.4 |4.7.4
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-12 15:17:08 UTC ---
GCC 4.6.4 has been released and the branch has been closed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug rtl-optimization/54919] [4.7 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
` (8 preceding siblings ...)
2013-04-12 15:18 ` [Bug rtl-optimization/54919] [4.7 " jakub at gcc dot gnu.org
@ 2014-06-12 13:18 ` rguenth at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54919
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|4.7.4 |4.8.0
Known to fail|4.7.3 |4.7.4
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.8.0.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-06-12 13:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-13 10:18 [Bug rtl-optimization/54919] New: [4.6/4.7/4.8 Regression] gcc.dg/torture/pr54877.c FAILs with -fvariable-expansion-in-unroller zsojka at seznam dot cz
2012-10-13 10:39 ` [Bug rtl-optimization/54919] " steven at gcc dot gnu.org
2012-10-13 16:38 ` steven at gcc dot gnu.org
2012-10-13 18:06 ` hubicka at gcc dot gnu.org
2012-10-13 21:51 ` steven at gcc dot gnu.org
2012-10-14 19:29 ` steven at gcc dot gnu.org
2012-10-14 20:31 ` [Bug rtl-optimization/54919] [4.6/4.7 " steven at gcc dot gnu.org
2012-10-14 20:32 ` steven at gcc dot gnu.org
2013-04-03 9:45 ` rguenth at gcc dot gnu.org
2013-04-12 15:18 ` [Bug rtl-optimization/54919] [4.7 " jakub at gcc dot gnu.org
2014-06-12 13:18 ` 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).