public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] arc: Fail conditional move expand patterns
@ 2022-02-25 12:50 Claudiu Zissulescu
  2022-02-25 13:29 ` Robin Dapp
  0 siblings, 1 reply; 3+ messages in thread
From: Claudiu Zissulescu @ 2022-02-25 12:50 UTC (permalink / raw)
  To: gcc-patches, fbedard

If the movcc comparison is not valid it triggers an assert in the
current implementation.  This behavior is not needed as we can FAIL
the movcc expand pattern.

gcc/
	* config/arc/arc.cc (gen_compare_reg): Return NULL_RTX if the
	comparison is not valid.
	* config/arc/arc.md (movsicc): Fail if comparison is not valid.
	(movdicc): Likewise.
	(movsfcc): Likewise.
	(movdfcc): Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
---
 gcc/config/arc/arc.cc |  3 ++-
 gcc/config/arc/arc.md | 25 ++++++++++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc
index 8cc173519ab..c27ba99eb60 100644
--- a/gcc/config/arc/arc.cc
+++ b/gcc/config/arc/arc.cc
@@ -2256,7 +2256,8 @@ gen_compare_reg (rtx comparison, machine_mode omode)
   cmode = GET_MODE (x);
   if (cmode == VOIDmode)
     cmode = GET_MODE (y);
-  gcc_assert (cmode == SImode || cmode == SFmode || cmode == DFmode);
+  if (cmode != SImode && cmode != SFmode && cmode != DFmode)
+    return NULL_RTX;
   if (cmode == SImode)
     {
       if (!register_operand (x, SImode))
diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md
index ace3cb70424..39b358052c1 100644
--- a/gcc/config/arc/arc.md
+++ b/gcc/config/arc/arc.md
@@ -1618,8 +1618,11 @@ (define_expand "movsicc"
 		         (match_operand:SI 2 "nonmemory_operand" "")
  		         (match_operand:SI 3 "register_operand" "")))]
   ""
-  "operands[1] = gen_compare_reg (operands[1], VOIDmode);")
-
+  "
+  operands[1] = gen_compare_reg (operands[1], VOIDmode);
+  if (operands[1] == NULL_RTX)
+    FAIL;
+  ")
 
 (define_expand "movdicc"
   [(set (match_operand:DI 0 "dest_reg_operand" "")
@@ -1627,7 +1630,11 @@ (define_expand "movdicc"
 		        (match_operand:DI 2 "nonmemory_operand" "")
 		        (match_operand:DI 3 "register_operand" "")))]
   ""
-  "operands[1] = gen_compare_reg (operands[1], VOIDmode);")
+  "
+  operands[1] = gen_compare_reg (operands[1], VOIDmode);
+  if (operands[1] == NULL_RTX)
+    FAIL;
+  ")
 
 
 (define_expand "movsfcc"
@@ -1636,7 +1643,11 @@ (define_expand "movsfcc"
 		      (match_operand:SF 2 "nonmemory_operand" "")
 		      (match_operand:SF 3 "register_operand" "")))]
   ""
-  "operands[1] = gen_compare_reg (operands[1], VOIDmode);")
+  "
+  operands[1] = gen_compare_reg (operands[1], VOIDmode);
+  if (operands[1] == NULL_RTX)
+    FAIL;
+  ")
 
 (define_expand "movdfcc"
   [(set (match_operand:DF 0 "dest_reg_operand" "")
@@ -1644,7 +1655,11 @@ (define_expand "movdfcc"
 		      (match_operand:DF 2 "nonmemory_operand" "")
 		      (match_operand:DF 3 "register_operand" "")))]
   ""
-  "operands[1] = gen_compare_reg (operands[1], VOIDmode);")
+  "
+  operands[1] = gen_compare_reg (operands[1], VOIDmode);
+  if (operands[1] == NULL_RTX)
+    FAIL;
+  ")
 
 (define_insn "*movsicc_insn"
   [(set (match_operand:SI 0 "dest_reg_operand" "=w,w")
-- 
2.35.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [committed] arc: Fail conditional move expand patterns
  2022-02-25 12:50 [committed] arc: Fail conditional move expand patterns Claudiu Zissulescu
@ 2022-02-25 13:29 ` Robin Dapp
  2022-02-28  9:45   ` Claudiu Zissulescu Ianculescu
  0 siblings, 1 reply; 3+ messages in thread
From: Robin Dapp @ 2022-02-25 13:29 UTC (permalink / raw)
  To: Claudiu Zissulescu, gcc-patches, fbedard, Jeff Law

> If the movcc comparison is not valid it triggers an assert in the
> current implementation.  This behavior is not needed as we can FAIL
> the movcc expand pattern.

In case of a MODE_CC comparison you can also just return it as described
here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104154

or here: https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590639.html

If there already is a "CC comparison" the backend does not need to
create one and ifcvt can make use of this, creating better sequences.

Regards
 Robin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [committed] arc: Fail conditional move expand patterns
  2022-02-25 13:29 ` Robin Dapp
@ 2022-02-28  9:45   ` Claudiu Zissulescu Ianculescu
  0 siblings, 0 replies; 3+ messages in thread
From: Claudiu Zissulescu Ianculescu @ 2022-02-28  9:45 UTC (permalink / raw)
  To: Robin Dapp; +Cc: gcc-patches, Francois Bedard, Jeff Law

Hi Robin,

I don't know how I missed your arc related patch, I'll bootstrap and test
your patch asap.

Thanks,
Claudiu


On Fri, Feb 25, 2022 at 3:29 PM Robin Dapp <rdapp@linux.ibm.com> wrote:

> > If the movcc comparison is not valid it triggers an assert in the
> > current implementation.  This behavior is not needed as we can FAIL
> > the movcc expand pattern.
>
> In case of a MODE_CC comparison you can also just return it as described
> here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104154
>
> or here:
> https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590639.html
>
> If there already is a "CC comparison" the backend does not need to
> create one and ifcvt can make use of this, creating better sequences.
>
> Regards
>  Robin
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-28  9:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-25 12:50 [committed] arc: Fail conditional move expand patterns Claudiu Zissulescu
2022-02-25 13:29 ` Robin Dapp
2022-02-28  9:45   ` Claudiu Zissulescu Ianculescu

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).