public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
@ 2015-02-27 13:09 ktkachov at gcc dot gnu.org
2015-02-27 13:20 ` [Bug rtl-optimization/65235] [4.8/4.9/5 " rguenth at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-02-27 13:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
Bug ID: 65235
Summary: [4.8, 4.9, 5 Regression] Simplifying vec_select of
vec_concat miscompiles when first element of
vec_concat is const_int
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ktkachov at gcc dot gnu.org
Target: aarch64
This aarch64 intrinsics testcase aborts.
#include "arm_neon.h"
int main (int argc, char** argv)
{
int64x1_t val1;
int64x1_t val2;
int64x1_t val3;
uint64x1_t val13;
uint64x2_t val14;
uint64_t got;
uint64_t exp;
val1 = vcreate_s64(UINT64_C(0xffffffff80008000));
val2 = vcreate_s64(UINT64_C(0x0000f38d00000000));
val3 = vcreate_s64(UINT64_C(0xffff7fff0000809b));
// Expect: "val13" = 8000000000001553
val13 = vcreate_u64 (UINT64_C(0x8000000000001553));
// Expect: "val14" = 0010 0000 0000 0002 0000 0000 0000 0000
val14 = vcombine_u64(vcgt_s64(vqrshl_s64(val1, val2),
vshr_n_s64(val3, 18)),
vshr_n_u64(val13, 11));
/* Should be 0000000000000000. */
got = vgetq_lane_u64(val14, 0);
exp = 0;
if(exp != got)
__builtin_abort ();
}
Investigation shows that the problem is in the simplify-rtx machinery:
Combine tries to combine:
(insn 72 71 73 2 (set (reg:V2DI 117 [ D.18177 ])
(vec_concat:V2DI (reg:DI 176 [ D.18179 ])
(reg:DI 114 [ D.18168 ])))
(expr_list:REG_DEAD (reg:DI 176 [ D.18179 ])
(expr_list:REG_DEAD (reg:DI 114 [ D.18168 ])
and
(insn 104 102 105 2 (set (reg:DI 193 [ D.18168 ])
(vec_select:DI (reg:V2DI 117 [ D.18177 ])
(parallel [
(const_int 0 [0])
])))
(expr_list:REG_DEAD (reg:V2DI 117 [ D.18177 ])
(nil)))
but ends up generating:
(set (reg:DI 193 [ D.18168 ])
(reg:DI 114 [ D.18168 ]))
i.e. it picks element 1 instead of the requested element 0.
This happens during combine where it tries to to simplify a vec_select 0 of the
intermediate rtx:
(vec_concat:V2DI (const_int -1 [0xffffffffffffffff])
(reg:DI 114 [ D.18166 ]))
The relevant code in simplify-rtx has been there for some time and is broken
for all release branches. I have a patch in testing...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] [4.8/4.9/5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
@ 2015-02-27 13:20 ` rguenth at gcc dot gnu.org
2015-02-27 13:21 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-02-27 13:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |5.0
Summary|[4.8, 4.9, 5 Regression] |[4.8/4.9/5 Regression]
|Simplifying vec_select of |Simplifying vec_select of
|vec_concat miscompiles when |vec_concat miscompiles when
|first element of vec_concat |first element of vec_concat
|is const_int |is const_int
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] [4.8/4.9/5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
2015-02-27 13:20 ` [Bug rtl-optimization/65235] [4.8/4.9/5 " rguenth at gcc dot gnu.org
@ 2015-02-27 13:21 ` rguenth at gcc dot gnu.org
2015-02-27 16:20 ` ktkachov at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-02-27 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|5.0 |4.8.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] [4.8/4.9/5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
2015-02-27 13:20 ` [Bug rtl-optimization/65235] [4.8/4.9/5 " rguenth at gcc dot gnu.org
2015-02-27 13:21 ` rguenth at gcc dot gnu.org
@ 2015-02-27 16:20 ` ktkachov at gcc dot gnu.org
2015-02-27 16:30 ` ktkachov at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-02-27 16:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
--- Comment #2 from ktkachov at gcc dot gnu.org ---
(In reply to Aldy Hernandez from comment #1)
> Hi. The known to work field is empty. Is this a regression?
>
> I can't reproduce on a cross build to --target=aarch64-linux by running cc1.
> What options causes this to fail? Could you post a preprocessed file for
> the test?
-O2 does it for me. I didn't try anything earlier than 4.8 (since they're not
maintained) but the offending code has been there since 2005:
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3551) rtx vec =
trueop0;
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3552) int offset =
INTVAL (XVECEXP (trueop1, 0, 0)) * GET_MODE_SIZE (mode);
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3553)
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3554) /* Try to
find the element in the VEC_CONCAT. */
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3555) while
(GET_MODE (vec) != mode
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3556) &&
GET_CODE (vec) == VEC_CONCAT)
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3557) {
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3558)
HOST_WIDE_INT vec_size = GET_MODE_SIZE (GET_MODE (XEXP (vec, 0)));
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3559) if
(offset < vec_size)
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3560) vec =
XEXP (vec, 0);
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3561) else
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3562) {
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3563)
offset -= vec_size;
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3564) vec =
XEXP (vec, 1);
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3565) }
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3566) vec =
avoid_constant_pool_reference (vec);
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3567) }
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3568)
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3569) if (GET_MODE
(vec) == mode)
6516cbaf (bonzini 2005-12-16 09:24:19 +0000 3570) return vec;
and aarch64 wasn't there before 4.8...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] [4.8/4.9/5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (2 preceding siblings ...)
2015-02-27 16:20 ` ktkachov at gcc dot gnu.org
@ 2015-02-27 16:30 ` ktkachov at gcc dot gnu.org
2015-02-27 16:53 ` ktkachov at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-02-27 16:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
--- Comment #3 from ktkachov at gcc dot gnu.org ---
gah, sorry, the field is not wide enough to show the output of git blame
properly...
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] [4.8/4.9/5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (3 preceding siblings ...)
2015-02-27 16:30 ` ktkachov at gcc dot gnu.org
@ 2015-02-27 16:53 ` ktkachov at gcc dot gnu.org
2015-02-27 16:56 ` ktkachov at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-02-27 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
--- Comment #5 from ktkachov at gcc dot gnu.org ---
Created attachment 34891
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34891&action=edit
Self-contained testcase
Here's a testcase with the relevant parts of arm_neon.h extracted.
This aborts for me on aarch64-none-linux-gnu and aarch64-none-elf
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] [4.8/4.9/5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (4 preceding siblings ...)
2015-02-27 16:53 ` ktkachov at gcc dot gnu.org
@ 2015-02-27 16:56 ` ktkachov at gcc dot gnu.org
2015-03-02 11:06 ` [Bug rtl-optimization/65235] " jgreenhalgh at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-02-27 16:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
--- Comment #6 from ktkachov at gcc dot gnu.org ---
> Hmmm... fine line, but maybe this isn't a regression?
I guess it isn't a regression in the release branches, but it is wrong-code
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (5 preceding siblings ...)
2015-02-27 16:56 ` ktkachov at gcc dot gnu.org
@ 2015-03-02 11:06 ` jgreenhalgh at gcc dot gnu.org
2015-03-12 13:41 ` ktkachov at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jgreenhalgh at gcc dot gnu.org @ 2015-03-02 11:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
James Greenhalgh <jgreenhalgh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|aarch64 |aarch64*-*-*
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-02
CC| |jgreenhalgh at gcc dot gnu.org
Host| |*-*-*
Ever confirmed|0 |1
--- Comment #7 from James Greenhalgh <jgreenhalgh at gcc dot gnu.org> ---
The tescase from comment 5 fails for me at -O3 on an aarch64-none-elf cross
compiler (r221086), this also fails for native aarch64-none-linux-gnu.
As with Kyrill, I see:
(insn 16 15 17 2 (set (reg:V2DI 80 [ D.2809 ])
(vec_concat:V2DI (reg:DI 95 [ D.2812 ])
(reg:DI 77 [ D.2806 ]))) reduced.c:19 1386
{aarch64_combine_internaldi}
(expr_list:REG_DEAD (reg:DI 95 [ D.2812 ])
(expr_list:REG_DEAD (reg:DI 77 [ D.2806 ])
(expr_list:REG_EQUAL (vec_concat:V2DI (reg:DI 95 [ D.2812 ])
(const_int 4503599627370498 [0x10000000000002]))
(nil)))))
(insn 17 16 18 2 (set (reg:DI 96 [ D.2806 ])
(vec_select:DI (reg:V2DI 80 [ D.2809 ])
(parallel [
(const_int 0 [0])
]))) reduced.c:14 1372 {aarch64_get_lanev2di}
(expr_list:REG_DEAD (reg:V2DI 80 [ D.2809 ])
(nil)))
----
Combine:
Trying 16 -> 17:
Successfully matched this instruction:
(set (reg:DI 96 [ D.2806 ])
(reg:DI 77 [ D.2806 ]))
---
Which is bogus, the correct rewrite would be to:
(set (reg:DI 96 [ D.2806 ])
(reg:DI 95 [ D.2812 ]))
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (6 preceding siblings ...)
2015-03-02 11:06 ` [Bug rtl-optimization/65235] " jgreenhalgh at gcc dot gnu.org
@ 2015-03-12 13:41 ` ktkachov at gcc dot gnu.org
2015-03-12 13:43 ` ktkachov at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-03-12 13:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
--- Comment #8 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Thu Mar 12 13:40:50 2015
New Revision: 221387
URL: https://gcc.gnu.org/viewcvs?rev=221387&root=gcc&view=rev
Log:
[simplify-rtx] PR 65235: Calculate element size correctly when simplifying
(vec_select (vec_concat (const_int) (...)) [...])
PR rtl-optimization 65235
* simplify-rtx.c (simplify_binary_operation_1, VEC_SELECT case):
When first element of vec_concat is const_int, calculate its size
using second element.
PR rtl-optimization 65235
* gcc.target/aarch64/pr65235_1.c: New test.
Added:
trunk/gcc/testsuite/gcc.target/aarch64/pr65235_1.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/simplify-rtx.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (7 preceding siblings ...)
2015-03-12 13:41 ` ktkachov at gcc dot gnu.org
@ 2015-03-12 13:43 ` ktkachov at gcc dot gnu.org
2015-03-19 10:29 ` ktkachov at gcc dot gnu.org
2015-06-23 9:01 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-03-12 13:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
ktkachov at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |5.0
Known to fail|5.0 |
--- Comment #9 from ktkachov at gcc dot gnu.org ---
Fixed on trunk. Will backport to branches later.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (8 preceding siblings ...)
2015-03-12 13:43 ` ktkachov at gcc dot gnu.org
@ 2015-03-19 10:29 ` ktkachov at gcc dot gnu.org
2015-06-23 9:01 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2015-03-19 10:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
--- Comment #10 from ktkachov at gcc dot gnu.org ---
Author: ktkachov
Date: Thu Mar 19 09:58:42 2015
New Revision: 221511
URL: https://gcc.gnu.org/viewcvs?rev=221511&root=gcc&view=rev
Log:
[simplify-rtx] PR 65235: Calculate element size correctly when simplifying
(vec_select (vec_concat (const_int) (...)) [...])
Backport from mainline
2015-03-12 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR rtl-optimization/65235
* simplify-rtx.c (simplify_binary_operation_1, VEC_SELECT case):
When first element of vec_concat is const_int, calculate its size
using second element.
PR rtl-optimization/65235
* gcc.target/aarch64/pr65235_1.c: New test.
Added:
branches/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/pr65235_1.c
Modified:
branches/gcc-4_9-branch/gcc/ChangeLog
branches/gcc-4_9-branch/gcc/simplify-rtx.c
branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug rtl-optimization/65235] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
` (9 preceding siblings ...)
2015-03-19 10:29 ` ktkachov at gcc dot gnu.org
@ 2015-06-23 9:01 ` rguenth at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-23 9:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65235
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.9.3
Resolution|--- |FIXED
Target Milestone|4.8.5 |4.9.3
Known to fail|4.8.4, 4.9.3 |4.8.5, 4.9.2
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed for 4.9.3.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-06-23 9:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27 13:09 [Bug rtl-optimization/65235] New: [4.8, 4.9, 5 Regression] Simplifying vec_select of vec_concat miscompiles when first element of vec_concat is const_int ktkachov at gcc dot gnu.org
2015-02-27 13:20 ` [Bug rtl-optimization/65235] [4.8/4.9/5 " rguenth at gcc dot gnu.org
2015-02-27 13:21 ` rguenth at gcc dot gnu.org
2015-02-27 16:20 ` ktkachov at gcc dot gnu.org
2015-02-27 16:30 ` ktkachov at gcc dot gnu.org
2015-02-27 16:53 ` ktkachov at gcc dot gnu.org
2015-02-27 16:56 ` ktkachov at gcc dot gnu.org
2015-03-02 11:06 ` [Bug rtl-optimization/65235] " jgreenhalgh at gcc dot gnu.org
2015-03-12 13:41 ` ktkachov at gcc dot gnu.org
2015-03-12 13:43 ` ktkachov at gcc dot gnu.org
2015-03-19 10:29 ` ktkachov at gcc dot gnu.org
2015-06-23 9:01 ` 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).