* [PATCH] arm: Fix ICE caused by arm_gen_discompare_reg [PR94292]
@ 2020-03-25 7:21 Jakub Jelinek
2020-03-25 17:51 ` Richard Earnshaw (lists)
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2020-03-25 7:21 UTC (permalink / raw)
To: Richard Earnshaw, Ramana Radhakrishnan, Kyrylo Tkachov; +Cc: gcc-patches
Hi!
The following testcase ICEs, because arm_gen_discompare_reg creates invalid
RTL which then propagates into DEBUG_INSNs and ICEs while handling them.
The problem is that this function emits
(insn 18 17 19 2 (set (reg:CC_DNE 100 cc)
(compare (ior:SI (ne:SI (subreg:SI (reg:DI 129) 0)
(subreg:SI (reg:DI 114 [ _2 ]) 0))
(ne:SI (subreg:SI (reg:DI 129) 4)
(subreg:SI (reg:DI 114 [ _2 ]) 4)))
(const_int 0 [0]))) "pr94292.c":7:11 325 {*cmp_ior}
(nil))
and the invalid thing is that the COMPARE has VOIDmode. Setting a
non-VOIDmode SET_DEST to VOIDmode SET_SRC is only valid if the SET_SRC is
CONST_INT/CONST_DOUBLE.
The following patch fixes it by giving the COMPARE the same mode as it gives
to the SET_DEST cc register.
Bootstrapped/regtested on armv7hl-linux-gnueabi, ok for trunk?
2020-03-25 Jakub Jelinek <jakub@redhat.com>
PR target/94292
* config/arm/arm.c (arm_gen_discompare_reg): Set mode of COMPARE to
mode rather than VOIDmode.
* gcc.dg/pr94292.c: New test.
--- gcc/config/arm/arm.c.jj 2020-03-18 19:25:33.000000000 +0100
+++ gcc/config/arm/arm.c 2020-03-24 13:14:38.568689174 +0100
@@ -15763,7 +15763,7 @@ arm_gen_dicompare_reg (rtx_code code, rt
cc_reg = gen_rtx_REG (mode, CC_REGNUM);
emit_insn (gen_rtx_SET (cc_reg,
- gen_rtx_COMPARE (VOIDmode, conjunction,
+ gen_rtx_COMPARE (mode, conjunction,
const0_rtx)));
return cc_reg;
}
--- gcc/testsuite/gcc.dg/pr94292.c.jj 2020-03-24 13:07:12.694449518 +0100
+++ gcc/testsuite/gcc.dg/pr94292.c 2020-03-24 13:06:53.720737198 +0100
@@ -0,0 +1,13 @@
+/* PR target/94292 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -g -fno-tree-dce" } */
+
+unsigned short a;
+unsigned long long b;
+
+long long
+foo (int d)
+{
+ d >>= a != (unsigned long long) -a;
+ return a + b;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] arm: Fix ICE caused by arm_gen_discompare_reg [PR94292]
2020-03-25 7:21 [PATCH] arm: Fix ICE caused by arm_gen_discompare_reg [PR94292] Jakub Jelinek
@ 2020-03-25 17:51 ` Richard Earnshaw (lists)
0 siblings, 0 replies; 2+ messages in thread
From: Richard Earnshaw (lists) @ 2020-03-25 17:51 UTC (permalink / raw)
To: Jakub Jelinek, Ramana Radhakrishnan, Kyrylo Tkachov; +Cc: gcc-patches
On 25/03/2020 07:21, Jakub Jelinek via Gcc-patches wrote:
> Hi!
>
> The following testcase ICEs, because arm_gen_discompare_reg creates invalid
> RTL which then propagates into DEBUG_INSNs and ICEs while handling them.
> The problem is that this function emits
> (insn 18 17 19 2 (set (reg:CC_DNE 100 cc)
> (compare (ior:SI (ne:SI (subreg:SI (reg:DI 129) 0)
> (subreg:SI (reg:DI 114 [ _2 ]) 0))
> (ne:SI (subreg:SI (reg:DI 129) 4)
> (subreg:SI (reg:DI 114 [ _2 ]) 4)))
> (const_int 0 [0]))) "pr94292.c":7:11 325 {*cmp_ior}
> (nil))
> and the invalid thing is that the COMPARE has VOIDmode. Setting a
> non-VOIDmode SET_DEST to VOIDmode SET_SRC is only valid if the SET_SRC is
> CONST_INT/CONST_DOUBLE.
> The following patch fixes it by giving the COMPARE the same mode as it gives
> to the SET_DEST cc register.
Ooops!
>
> Bootstrapped/regtested on armv7hl-linux-gnueabi, ok for trunk?
>
> 2020-03-25 Jakub Jelinek <jakub@redhat.com>
>
> PR target/94292
> * config/arm/arm.c (arm_gen_discompare_reg): Set mode of COMPARE to
> mode rather than VOIDmode.
>
It's arm_gen_dicompare_reg (no 's'). Similarly in the summary line and
elsewhere in the description.
> * gcc.dg/pr94292.c: New test.
Otherwise, OK.
R.
>
> --- gcc/config/arm/arm.c.jj 2020-03-18 19:25:33.000000000 +0100
> +++ gcc/config/arm/arm.c 2020-03-24 13:14:38.568689174 +0100
> @@ -15763,7 +15763,7 @@ arm_gen_dicompare_reg (rtx_code code, rt
> cc_reg = gen_rtx_REG (mode, CC_REGNUM);
>
> emit_insn (gen_rtx_SET (cc_reg,
> - gen_rtx_COMPARE (VOIDmode, conjunction,
> + gen_rtx_COMPARE (mode, conjunction,
> const0_rtx)));
> return cc_reg;
> }
> --- gcc/testsuite/gcc.dg/pr94292.c.jj 2020-03-24 13:07:12.694449518 +0100
> +++ gcc/testsuite/gcc.dg/pr94292.c 2020-03-24 13:06:53.720737198 +0100
> @@ -0,0 +1,13 @@
> +/* PR target/94292 */
> +/* { dg-do compile } */
> +/* { dg-options "-O1 -g -fno-tree-dce" } */
> +
> +unsigned short a;
> +unsigned long long b;
> +
> +long long
> +foo (int d)
> +{
> + d >>= a != (unsigned long long) -a;
> + return a + b;
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-25 17:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-25 7:21 [PATCH] arm: Fix ICE caused by arm_gen_discompare_reg [PR94292] Jakub Jelinek
2020-03-25 17:51 ` Richard Earnshaw (lists)
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).