public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds.
@ 2015-12-16 12:43 Dominik Vogt
  2015-12-18  9:56 ` Richard Sandiford
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Vogt @ 2015-12-16 12:43 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ulrich Weigand, Andreas Krebbel, rdsandiford

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

The attached patch fixes the handling of LABEL_REF in genrecog and
genpreds.

The current code assumes that X can have only a mode than PRED (X,
MODE) if X is CONST_INT, CONST_DOUBLE or CONST_WIDE_INT, but
actually that can be also the case for a LABEL_REF with VOIDmode.
Due to this it is necessary to add "const_int" (or similar) to
match_code of some predicates handling label_ref but not
const_int.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 335 bytes --]

gcc/ChangeLog

	* config/s390/predicates.md ("larl_operand"): Remove now superfluous
	const_int and const_double.
	* genrecog.c (safe_predicate_mode): Return false for VOIDmode
	LABEL_REFs even if the predicate does not handle const_int,
	const_double or const_wide_int.
	* genpreds.c (add_mode_tests): Treat LABEL_REF like CONST_INT.

[-- Attachment #3: 0001-Fix-broken-handling-of-LABEL_REF-in-genrecog-genpreds.patch --]
[-- Type: text/x-diff, Size: 2233 bytes --]

From a211b6e3e2a64bdf47507c0e6151f137bcd4641f Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Fri, 11 Dec 2015 17:14:25 +0100
Subject: [PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds.

The old code assumed that X can have only a mode than PRED (X, MODE) if X is
CONST_INT, CONST_DOUBLE or CONST_WIDE_INT, but actually that can be also the
case for LABEL_REF.  Due to this bug it was necessary to add "const_int" (or
similar) to match_code of some predicates handling label_ref but not const_int.
---
 gcc/config/s390/predicates.md | 5 +----
 gcc/genpreds.c                | 1 +
 gcc/genrecog.c                | 3 ++-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md
index 5c462c4..f7ab836 100644
--- a/gcc/config/s390/predicates.md
+++ b/gcc/config/s390/predicates.md
@@ -121,10 +121,7 @@
 ;;  Return true if OP a valid operand for the LARL instruction.
 
 (define_predicate "larl_operand"
-; Note: Although CONST_INT and CONST_DOUBLE are not handled in this predicate,
-; at least one of them needs to appear or otherwise safe_predicate_mode will
-; assume that a VOIDmode LABEL_REF is not accepted either (see genrecog.c).
-  (match_code "label_ref, symbol_ref, const, const_int, const_double")
+  (match_code "label_ref, symbol_ref, const")
 {
   /* Allow labels and local symbols.  */
   if (GET_CODE (op) == LABEL_REF)
diff --git a/gcc/genpreds.c b/gcc/genpreds.c
index eac2180..3791f6d 100644
--- a/gcc/genpreds.c
+++ b/gcc/genpreds.c
@@ -320,6 +320,7 @@ add_mode_tests (struct pred_data *p)
 	{
 	case CONST_INT:
 	case CONST_WIDE_INT:
+	case LABEL_REF:
 	  matches_const_scalar_int_p = true;
 	  break;
 
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index 599121f..81ea35b 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -3382,7 +3382,8 @@ safe_predicate_mode (const struct pred_data *pred, machine_mode mode)
   if (GET_MODE_CLASS (mode) == MODE_INT
       && (pred->codes[CONST_INT]
 	  || pred->codes[CONST_DOUBLE]
-	  || pred->codes[CONST_WIDE_INT]))
+	  || pred->codes[CONST_WIDE_INT]
+	  || pred->codes[LABEL_REF]))
     return false;
 
   return !pred->special && mode != VOIDmode;
-- 
2.3.0


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

* Re: [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds.
  2015-12-16 12:43 [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds Dominik Vogt
@ 2015-12-18  9:56 ` Richard Sandiford
  2015-12-22 11:13   ` Dominik Vogt
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2015-12-18  9:56 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ulrich Weigand, Andreas Krebbel

Dominik Vogt <vogt@linux.vnet.ibm.com> writes:
> The attached patch fixes the handling of LABEL_REF in genrecog and
> genpreds.
>
> The current code assumes that X can have only a mode than PRED (X,
> MODE) if X is CONST_INT, CONST_DOUBLE or CONST_WIDE_INT, but
> actually that can be also the case for a LABEL_REF with VOIDmode.
> Due to this it is necessary to add "const_int" (or similar) to
> match_code of some predicates handling label_ref but not
> const_int.

OK, thanks.

As mentioned in the other thread, I think LABEL_REFs shouldn't have
VOIDmode, so long-term we should be fixing the targets.  I agree this
is the correct workaround until that happens though.

Richard

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

* Re: [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds.
  2015-12-18  9:56 ` Richard Sandiford
@ 2015-12-22 11:13   ` Dominik Vogt
  2015-12-22 22:24     ` Richard Sandiford
  2015-12-23 11:07     ` Andreas Krebbel
  0 siblings, 2 replies; 5+ messages in thread
From: Dominik Vogt @ 2015-12-22 11:13 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Sandiford, Ulrich Weigand, Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

On Fri, Dec 18, 2015 at 09:55:54AM +0000, Richard Sandiford wrote:
> Dominik Vogt <vogt@linux.vnet.ibm.com> writes:
> > The attached patch fixes the handling of LABEL_REF in genrecog and
> > genpreds.
> >
> > The current code assumes that X can have only a mode than PRED (X,
> > MODE) if X is CONST_INT, CONST_DOUBLE or CONST_WIDE_INT, but
> > actually that can be also the case for a LABEL_REF with VOIDmode.
> > Due to this it is necessary to add "const_int" (or similar) to
> > match_code of some predicates handling label_ref but not
> > const_int.
> 
> OK, thanks.
> 
> As mentioned in the other thread, I think LABEL_REFs shouldn't have
> VOIDmode, so long-term we should be fixing the targets.  I agree this
> is the correct workaround until that happens though.

All right, in the mean time the patch has passed the test suite on
x86_64, s390x and s390.  See attached version 2 of the patch
(added just an additional comment in genpreds.c).

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-v2-ChangeLog --]
[-- Type: text/plain, Size: 335 bytes --]

gcc/ChangeLog

	* config/s390/predicates.md ("larl_operand"): Remove now superfluous
	const_int and const_double.
	* genrecog.c (safe_predicate_mode): Return false for VOIDmode
	LABEL_REFs even if the predicate does not handle const_int,
	const_double or const_wide_int.
	* genpreds.c (add_mode_tests): Treat LABEL_REF like CONST_INT.

[-- Attachment #3: 0001-v2-Fix-handling-of-LABEL_REF-in-safe_predicate_mode.patch --]
[-- Type: text/x-diff, Size: 2279 bytes --]

From 84c51fbb773cb62a24b150063428ba74e42f4146 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Fri, 11 Dec 2015 17:14:25 +0100
Subject: [PATCH] Fix handling of LABEL_REF in safe_predicate_mode.

The old code assumes that X can have only a mode than PRED (X, MODE) if X is
CONST_INT, CONST_DOUBLE or CONST_WIDE_INT, but actually that can be also the
case for LABEL_REF.  Due to this it was necessary to add "const_int" (or
similar) to match_code of some predicates handling label_ref but not const_int.
---
 gcc/config/s390/predicates.md | 5 +----
 gcc/genpreds.c                | 2 ++
 gcc/genrecog.c                | 3 ++-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md
index 02a1e4e..1211cf01 100644
--- a/gcc/config/s390/predicates.md
+++ b/gcc/config/s390/predicates.md
@@ -122,10 +122,7 @@
 ;;  Return true if OP a valid operand for the LARL instruction.
 
 (define_predicate "larl_operand"
-; Note: Although CONST_INT and CONST_DOUBLE are not handled in this predicate,
-; at least one of them needs to appear or otherwise safe_predicate_mode will
-; assume that a VOIDmode LABEL_REF is not accepted either (see genrecog.c).
-  (match_code "label_ref, symbol_ref, const, const_int, const_double")
+  (match_code "label_ref, symbol_ref, const")
 {
   /* Allow labels and local symbols.  */
   if (GET_CODE (op) == LABEL_REF)
diff --git a/gcc/genpreds.c b/gcc/genpreds.c
index eac2180..c82113d 100644
--- a/gcc/genpreds.c
+++ b/gcc/genpreds.c
@@ -320,6 +320,8 @@ add_mode_tests (struct pred_data *p)
 	{
 	case CONST_INT:
 	case CONST_WIDE_INT:
+	  /* Special handling for (VOIDmode) LABEL_REFs.  */
+	case LABEL_REF:
 	  matches_const_scalar_int_p = true;
 	  break;
 
diff --git a/gcc/genrecog.c b/gcc/genrecog.c
index 599121f..81ea35b 100644
--- a/gcc/genrecog.c
+++ b/gcc/genrecog.c
@@ -3382,7 +3382,8 @@ safe_predicate_mode (const struct pred_data *pred, machine_mode mode)
   if (GET_MODE_CLASS (mode) == MODE_INT
       && (pred->codes[CONST_INT]
 	  || pred->codes[CONST_DOUBLE]
-	  || pred->codes[CONST_WIDE_INT]))
+	  || pred->codes[CONST_WIDE_INT]
+	  || pred->codes[LABEL_REF]))
     return false;
 
   return !pred->special && mode != VOIDmode;
-- 
2.3.0


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

* Re: [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds.
  2015-12-22 11:13   ` Dominik Vogt
@ 2015-12-22 22:24     ` Richard Sandiford
  2015-12-23 11:07     ` Andreas Krebbel
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Sandiford @ 2015-12-22 22:24 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ulrich Weigand, Andreas Krebbel

Dominik Vogt <vogt@linux.vnet.ibm.com> writes:
> On Fri, Dec 18, 2015 at 09:55:54AM +0000, Richard Sandiford wrote:
>> Dominik Vogt <vogt@linux.vnet.ibm.com> writes:
>> > The attached patch fixes the handling of LABEL_REF in genrecog and
>> > genpreds.
>> >
>> > The current code assumes that X can have only a mode than PRED (X,
>> > MODE) if X is CONST_INT, CONST_DOUBLE or CONST_WIDE_INT, but
>> > actually that can be also the case for a LABEL_REF with VOIDmode.
>> > Due to this it is necessary to add "const_int" (or similar) to
>> > match_code of some predicates handling label_ref but not
>> > const_int.
>> 
>> OK, thanks.
>> 
>> As mentioned in the other thread, I think LABEL_REFs shouldn't have
>> VOIDmode, so long-term we should be fixing the targets.  I agree this
>> is the correct workaround until that happens though.
>
> All right, in the mean time the patch has passed the test suite on
> x86_64, s390x and s390.  See attached version 2 of the patch
> (added just an additional comment in genpreds.c).

This is OK too, thanks.

"matches_const_scalar_int_p" is now a bit of a misnomer (it was supposed
to be tied to CONST_SCALAR_INT_P) but I think we can live with that.
(Especially since this is supposed to be "temporary"...)

Richard

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

* Re: [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds.
  2015-12-22 11:13   ` Dominik Vogt
  2015-12-22 22:24     ` Richard Sandiford
@ 2015-12-23 11:07     ` Andreas Krebbel
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Krebbel @ 2015-12-23 11:07 UTC (permalink / raw)
  To: gcc-patches, vogt

On 12/22/2015 12:12 PM, Dominik Vogt wrote:
> All right, in the mean time the patch has passed the test suite on
> x86_64, s390x and s390.  See attached version 2 of the patch
> (added just an additional comment in genpreds.c).

Applied. Thanks!

-Andreas-


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

end of thread, other threads:[~2015-12-23 11:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-16 12:43 [RFC][PATCH] Fix broken handling of LABEL_REF in genrecog + genpreds Dominik Vogt
2015-12-18  9:56 ` Richard Sandiford
2015-12-22 11:13   ` Dominik Vogt
2015-12-22 22:24     ` Richard Sandiford
2015-12-23 11:07     ` Andreas Krebbel

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