public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jeff Law <law@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] Fix expand_binop (PR middle-end/88032)
Date: Fri, 16 Nov 2018 08:49:00 -0000	[thread overview]
Message-ID: <20181116084950.GE11625@tucnak> (raw)
In-Reply-To: <f1bbbd7c-df9e-8e30-9037-98703fd4a1a1@redhat.com>

Hi!

On Wed, Nov 14, 2018 at 09:35:30AM -0700, Jeff Law wrote:
> +	* optabs.c (expand_binop): Pass INT_MODE to operand_subword_force
> +	iff the operand is a constant.

This broke gcc.target/i386/pr80173.c testcase.  The problem is
that while operand_subword handles VOIDmode last argument just fine
by using GET_MODE (op), so it is only important to use non-VOIDmode if
op has VOIDmode.  But, operand_subword_force actually has a different
behavior, if mode is VOIDmode (or BLKmode), it acts just as operand_subword
followed by assertion that it succeeded, rather than by trying to deal with
failed operand_subword by forcing it into a pseudo.

In the testcase, op is a hard register, on which operand_subword fails, but
if it is forced into pseudo, it succeeds.

The following patch arranges it by never passing VOIDmode to
operand_subword_force, pass int_mode as previously if opN has VOIDmode, but
instead of passing VOIDmode otherwise pass the actual mode of the opN
operand.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-11-16  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/88032
	* optabs.c (expand_binop): For op0_mode use GET_MODE (op0), unless it
	is VOIDmode, in which case use int_mode.  Similarly for op1_mode.

--- gcc/optabs.c.jj	2018-11-14 17:42:53.044049213 +0100
+++ gcc/optabs.c	2018-11-15 15:45:35.949378049 +0100
@@ -1377,8 +1377,12 @@ expand_binop (machine_mode mode, optab b
       start_sequence ();
 
       /* Do the actual arithmetic.  */
-      enum machine_mode op0_mode = CONSTANT_P (op0) ? int_mode : VOIDmode;
-      enum machine_mode op1_mode = CONSTANT_P (op1) ? int_mode : VOIDmode;
+      enum machine_mode op0_mode = GET_MODE (op0);
+      enum machine_mode op1_mode = GET_MODE (op1);
+      if (op0_mode == VOIDmode)
+	op0_mode = int_mode;
+      if (op1_mode == VOIDmode)
+	op1_mode = int_mode;
       for (i = 0; i < GET_MODE_BITSIZE (int_mode) / BITS_PER_WORD; i++)
 	{
 	  rtx target_piece = operand_subword (target, i, 1, int_mode);


	Jakub

  reply	other threads:[~2018-11-16  8:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-14 16:35 [committed] Fix rl78 newlib build failure due to bogus operand_subword_force argument Jeff Law
2018-11-16  8:49 ` Jakub Jelinek [this message]
2018-11-16 15:41   ` [PATCH] Fix expand_binop (PR middle-end/88032) Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116084950.GE11625@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).