public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg
@ 2012-05-14 22:52 meadori at codesourcery dot com
2012-05-14 22:54 ` [Bug rtl-optimization/53352] " meadori at codesourcery dot com
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: meadori at codesourcery dot com @ 2012-05-14 22:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
Bug #: 53352
Summary: Incorrect CSE optimization on RTL expressions with a
paradoxical subreg
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: meadori@codesourcery.com
Host: GNU/Linux
Target: arm-none-linux-gnueabi
The attached reproduction case exhibits what I believe to be a bug
in the CSE pass. The problem can be reproduced from the mainline
at r187470. The compiler was built for arm-none-linux-gnueabi
and the reproduction case was compiled with -O3.
Out of the gate the expanded RTL of interest looks like:
(insn 12 11 13 3 (set (reg:SI 140)
(lshiftrt:SI (reg/v:SI 135 [ tmp1 ])
(const_int 16 [0x10])))
(nil))
(insn 13 12 14 3 (set (reg:QI 141)
(subreg:QI (reg:SI 140) 0))
(nil))
(insn 14 13 15 3 (set (reg:SI 142)
(subreg:SI (reg:QI 141) 0))
(nil))
(insn 15 14 16 3 (set (reg:SI 134 [ tmp1$2 ])
(and:SI (reg:SI 142)
(const_int 255 [0xff])))
(nil))
...
(insn 29 28 30 3 (set (reg:SI 0 r0)
(const_int 0 [0]))
(nil))
after "cse1" things look like:
(insn 12 11 13 2 (set (reg:SI 140)
(const_int 65280 [0xff00]))
(nil))
(insn 13 12 14 2 (set (reg:QI 141)
(subreg:QI (reg:SI 140) 0))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
;; This is *not* equal to zero because the upper
;; two bytes are undefined.
(insn 14 13 15 2 (set (reg:SI 142)
(subreg:SI (reg:QI 141) 0))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
(insn 15 14 16 2 (set (reg:SI 134 [ tmp1$2 ])
(reg:SI 142))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
...
(insn 29 28 30 2 (set (reg:SI 0 r0)
(reg:SI 142))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
I believe the REG_EQUAL note on the set involving a paradoxical subreg
is incorrect. It eventually causes 0xFF00 to be passed to the function
'foo'.
I doesn't look like 'equiv_constant' handles the paradoxical subreg case
correctly. I fixed it as follows and am testing the patch now:
Index: gcc/cse.c
===================================================================
--- gcc/cse.c (revision 187470)
+++ gcc/cse.c (working copy)
@@ -3786,8 +3786,11 @@
}
}
- /* Otherwise see if we already have a constant for the inner REG. */
+ /* Otherwise see if we already have a constant for the inner REG.
+ Don't bother with paradoxical subregs because we have no way
+ of knowing what the upper bytes are. */
if (REG_P (SUBREG_REG (x))
+ && (GET_MODE_SIZE (mode) <= GET_MODE_SIZE (imode))
&& (new_rtx = equiv_constant (SUBREG_REG (x))) != 0)
return simplify_subreg (mode, new_rtx, imode, SUBREG_BYTE (x));
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
@ 2012-05-14 22:54 ` meadori at codesourcery dot com
2012-05-17 16:42 ` mikpe at it dot uu.se
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: meadori at codesourcery dot com @ 2012-05-14 22:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #1 from Meador Inge <meadori at codesourcery dot com> 2012-05-14 22:52:41 UTC ---
Created attachment 27405
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27405
Reproduction case
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
2012-05-14 22:54 ` [Bug rtl-optimization/53352] " meadori at codesourcery dot com
@ 2012-05-17 16:42 ` mikpe at it dot uu.se
2012-05-17 16:47 ` meadori at codesourcery dot com
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu.se @ 2012-05-17 16:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
Mikael Pettersson <mikpe at it dot uu.se> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu.se
--- Comment #2 from Mikael Pettersson <mikpe at it dot uu.se> 2012-05-17 16:36:38 UTC ---
Can you make the test case standalone? Currently it compiles but doesn't link,
and there's nothing in it to suggest where the error could be observed.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
2012-05-14 22:54 ` [Bug rtl-optimization/53352] " meadori at codesourcery dot com
2012-05-17 16:42 ` mikpe at it dot uu.se
@ 2012-05-17 16:47 ` meadori at codesourcery dot com
2012-05-17 18:35 ` steven at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: meadori at codesourcery dot com @ 2012-05-17 16:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #3 from Meador Inge <meadori at codesourcery dot com> 2012-05-17 16:42:04 UTC ---
It can easily be seen my inspection of the assembly code. As I mentioned
before, 0xFF00 gets passed to 'foo'. Anyway, I posted an executable case along
with my patch here: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg01042.html.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (2 preceding siblings ...)
2012-05-17 16:47 ` meadori at codesourcery dot com
@ 2012-05-17 18:35 ` steven at gcc dot gnu.org
2012-05-17 19:02 ` mikpe at it dot uu.se
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu.org @ 2012-05-17 18:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |steven at gcc dot gnu.org
--- Comment #4 from Steven Bosscher <steven at gcc dot gnu.org> 2012-05-17 18:29:27 UTC ---
(In reply to comment #3)
That test case isn't particularly good, either. If something like IPA-CP or
inlining becomes the default at -O1, your whole test cases optimizes to a
no-op. And, at least AFAICT, your test case doesn't even specifically test for
the incorrect transformation.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (3 preceding siblings ...)
2012-05-17 18:35 ` steven at gcc dot gnu.org
@ 2012-05-17 19:02 ` mikpe at it dot uu.se
2012-05-17 20:46 ` steven at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu.se @ 2012-05-17 19:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #5 from Mikael Pettersson <mikpe at it dot uu.se> 2012-05-17 18:35:00 UTC ---
There is no call to 'foo' in the test case here. I guess you meant 'bar', but
even so executable test cases are strongly preferred over manual inspection of
assembly code.
FWIW, using the test case in the gcc-patches submission I've reproduced the bug
with both gcc-4.6.3 and gcc-4.5.3 on armv5tel-linux-gnueabi.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (4 preceding siblings ...)
2012-05-17 19:02 ` mikpe at it dot uu.se
@ 2012-05-17 20:46 ` steven at gcc dot gnu.org
2012-05-17 22:02 ` meadori at codesourcery dot com
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu.org @ 2012-05-17 20:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #6 from Steven Bosscher <steven at gcc dot gnu.org> 2012-05-17 19:09:14 UTC ---
Mikael, is it possible for you to test if this is caused by this patch, please?
http://gcc.gnu.org/viewcvs?view=revision&revision=142443
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (5 preceding siblings ...)
2012-05-17 20:46 ` steven at gcc dot gnu.org
@ 2012-05-17 22:02 ` meadori at codesourcery dot com
2012-05-17 23:35 ` mikpe at it dot uu.se
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: meadori at codesourcery dot com @ 2012-05-17 22:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #7 from Meador Inge <meadori at codesourcery dot com> 2012-05-17 20:31:28 UTC ---
(In reply to comment #5)
> There is no call to 'foo' in the test case here. I guess you meant 'bar', but
> even so executable test cases are strongly preferred over manual inspection of
> assembly code.
Yup, 'bar'. Sorry.
> FWIW, using the test case in the gcc-patches submission I've reproduced the bug
> with both gcc-4.6.3 and gcc-4.5.3 on armv5tel-linux-gnueabi.
Thanks for checking that out.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (6 preceding siblings ...)
2012-05-17 22:02 ` meadori at codesourcery dot com
@ 2012-05-17 23:35 ` mikpe at it dot uu.se
2012-05-18 9:30 ` rsandifo at gcc dot gnu.org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: mikpe at it dot uu.se @ 2012-05-17 23:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #8 from Mikael Pettersson <mikpe at it dot uu.se> 2012-05-17 21:07:20 UTC ---
(In reply to comment #6)
> Mikael, is it possible for you to test if this is caused by this patch, please?
> http://gcc.gnu.org/viewcvs?view=revision&revision=142443
The error appears to be older than that, I can reproduce it with both r142442
and r142443.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (7 preceding siblings ...)
2012-05-17 23:35 ` mikpe at it dot uu.se
@ 2012-05-18 9:30 ` rsandifo at gcc dot gnu.org
2012-05-18 14:30 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rsandifo at gcc dot gnu.org @ 2012-05-18 9:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #9 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> 2012-05-18 09:04:47 UTC ---
Author: rsandifo
Date: Fri May 18 09:04:38 2012
New Revision: 187648
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187648
Log:
gcc/
2012-05-15 Meador Inge <meadori@codesourcery.com>
PR rtl-optimization/53352
* cse.c (equiv_constant): Ignore paradoxical subregs.
gcc/testsuite/
2012-05-15 Meador Inge <meadori@codesourcery.com>
PR rtl-optimization/53352
* gcc.dg/pr53352.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/pr53352.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cse.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (8 preceding siblings ...)
2012-05-18 9:30 ` rsandifo at gcc dot gnu.org
@ 2012-05-18 14:30 ` hjl.tools at gmail dot com
2012-07-13 16:24 ` ramana at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hjl.tools at gmail dot com @ 2012-05-18 14:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> 2012-05-18 14:16:46 UTC ---
The test fails on Linux/x86 and Linux/x86-64.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (9 preceding siblings ...)
2012-05-18 14:30 ` hjl.tools at gmail dot com
@ 2012-07-13 16:24 ` ramana at gcc dot gnu.org
2012-07-13 16:35 ` meadori at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: ramana at gcc dot gnu.org @ 2012-07-13 16:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ramana at gcc dot gnu.org
--- Comment #11 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> 2012-07-13 16:24:34 UTC ---
(In reply to comment #10)
> The test fails on Linux/x86 and Linux/x86-64.
http://gcc.gnu.org/ml/gcc-testresults/2012-07/msg00958.html doesn't suggest
this test fails anymore ?
HJ, should this now be marked as FIXED ?
ramana
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (10 preceding siblings ...)
2012-07-13 16:24 ` ramana at gcc dot gnu.org
@ 2012-07-13 16:35 ` meadori at gcc dot gnu.org
2013-02-04 0:05 ` pinskia at gcc dot gnu.org
2013-02-04 0:06 ` pinskia at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: meadori at gcc dot gnu.org @ 2012-07-13 16:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
meadori at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |meadori at gcc dot gnu.org
Resolution| |FIXED
--- Comment #12 from meadori at gcc dot gnu.org 2012-07-13 16:34:14 UTC ---
The test case was fixed:
http://gcc.gnu.org/viewcvs?view=revision&revision=187654.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (11 preceding siblings ...)
2012-07-13 16:35 ` meadori at gcc dot gnu.org
@ 2013-02-04 0:05 ` pinskia at gcc dot gnu.org
2013-02-04 0:06 ` pinskia at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-04 0:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.8.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug rtl-optimization/53352] Incorrect CSE optimization on RTL expressions with a paradoxical subreg
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
` (12 preceding siblings ...)
2013-02-04 0:05 ` pinskia at gcc dot gnu.org
@ 2013-02-04 0:06 ` pinskia at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-02-04 0:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53352
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |acn1 at cam dot ac.uk
--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-02-04 00:05:48 UTC ---
*** Bug 55108 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-02-04 0:06 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-14 22:52 [Bug rtl-optimization/53352] New: Incorrect CSE optimization on RTL expressions with a paradoxical subreg meadori at codesourcery dot com
2012-05-14 22:54 ` [Bug rtl-optimization/53352] " meadori at codesourcery dot com
2012-05-17 16:42 ` mikpe at it dot uu.se
2012-05-17 16:47 ` meadori at codesourcery dot com
2012-05-17 18:35 ` steven at gcc dot gnu.org
2012-05-17 19:02 ` mikpe at it dot uu.se
2012-05-17 20:46 ` steven at gcc dot gnu.org
2012-05-17 22:02 ` meadori at codesourcery dot com
2012-05-17 23:35 ` mikpe at it dot uu.se
2012-05-18 9:30 ` rsandifo at gcc dot gnu.org
2012-05-18 14:30 ` hjl.tools at gmail dot com
2012-07-13 16:24 ` ramana at gcc dot gnu.org
2012-07-13 16:35 ` meadori at gcc dot gnu.org
2013-02-04 0:05 ` pinskia at gcc dot gnu.org
2013-02-04 0:06 ` pinskia 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).