* [PATCH, rtl-optimization]: Fix PR77452, ICE: in plus_constant, at explow.c
@ 2016-09-04 14:08 Uros Bizjak
2016-09-05 10:34 ` Bernd Schmidt
0 siblings, 1 reply; 3+ messages in thread
From: Uros Bizjak @ 2016-09-04 14:08 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 822 bytes --]
Hello!
As shown in the PR [1], combine is able to simplify lowpart
CONST_VECTOR constant pool reference to its inner-mode reference.
However, plus_constant was not able to extract the constant from
narrowed access.
Attached patch teaches plus_constant how to handle this situation.
2016-09-04 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/77452
* explow.c (plus_constant) <case MEM>: Extract scalar constant from
inner-mode reference to a CONST_VECTOR constant in the constant pool.
2016-09-04 Uros Bizjak <ubizjak@gmail.com>
testsuite/ChangeLog:
PR rtl-optimization/77452
* gcc.target/i386/pr77452.c: New test.
Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
OK for mainline and gcc-6 branch?
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77452
Uros.
[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1441 bytes --]
Index: explow.c
===================================================================
--- explow.c (revision 239975)
+++ explow.c (working copy)
@@ -106,7 +106,15 @@ plus_constant (machine_mode mode, rtx x, HOST_WIDE
if (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
&& CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)))
{
- tem = plus_constant (mode, get_pool_constant (XEXP (x, 0)), c);
+ rtx cst = get_pool_constant (XEXP (x, 0));
+
+ if (GET_CODE (cst) == CONST_VECTOR
+ && GET_MODE_INNER (GET_MODE (cst)) == mode)
+ {
+ cst = gen_lowpart (mode, cst);
+ gcc_assert (cst);
+ }
+ tem = plus_constant (mode, cst, c);
tem = force_const_mem (GET_MODE (x), tem);
/* Targets may disallow some constants in the constant pool, thus
force_const_mem may return NULL_RTX. */
Index: testsuite/gcc.target/i386/pr77452.c
===================================================================
--- testsuite/gcc.target/i386/pr77452.c (nonexistent)
+++ testsuite/gcc.target/i386/pr77452.c (working copy)
@@ -0,0 +1,13 @@
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O -mavx512f -fno-split-wide-types --param max-combine-insns=2" } */
+
+typedef unsigned int U __attribute__((vector_size(64)));
+typedef unsigned __int128 V __attribute__((vector_size(64)));
+
+V
+foo(V v)
+{
+ v[0] = 1u << (( ((V)(U){1, 1, v[0]})[0]) & 0xf)
+ >> ((-~((V)(U){1, 1, v[0]})[0]) & 0xf);
+ return v;
+}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH, rtl-optimization]: Fix PR77452, ICE: in plus_constant, at explow.c
2016-09-04 14:08 [PATCH, rtl-optimization]: Fix PR77452, ICE: in plus_constant, at explow.c Uros Bizjak
@ 2016-09-05 10:34 ` Bernd Schmidt
2016-09-05 11:23 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Bernd Schmidt @ 2016-09-05 10:34 UTC (permalink / raw)
To: Uros Bizjak, gcc-patches
On 09/04/2016 02:12 PM, Uros Bizjak wrote:
> As shown in the PR [1], combine is able to simplify lowpart
> CONST_VECTOR constant pool reference to its inner-mode reference.
> However, plus_constant was not able to extract the constant from
> narrowed access.
>
> Attached patch teaches plus_constant how to handle this situation.
Ok. It looks like accesses to non-lowpart subregs would be handled by
not optimizing them as well rather than crashing.
Bernd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH, rtl-optimization]: Fix PR77452, ICE: in plus_constant, at explow.c
2016-09-05 10:34 ` Bernd Schmidt
@ 2016-09-05 11:23 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2016-09-05 11:23 UTC (permalink / raw)
To: Bernd Schmidt, Uros Bizjak, gcc-patches
On September 5, 2016 12:11:47 PM GMT+02:00, Bernd Schmidt <bschmidt@redhat.com> wrote:
>On 09/04/2016 02:12 PM, Uros Bizjak wrote:
>> As shown in the PR [1], combine is able to simplify lowpart
>> CONST_VECTOR constant pool reference to its inner-mode reference.
>> However, plus_constant was not able to extract the constant from
>> narrowed access.
>>
>> Attached patch teaches plus_constant how to handle this situation.
>
>Ok. It looks like accesses to non-lowpart subregs would be handled by
>not optimizing them as well rather than crashing.
Are we missing similar handling for complex integer constants?
Richard.
>
>Bernd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-05 10:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-04 14:08 [PATCH, rtl-optimization]: Fix PR77452, ICE: in plus_constant, at explow.c Uros Bizjak
2016-09-05 10:34 ` Bernd Schmidt
2016-09-05 11:23 ` Richard Biener
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).