This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix expand_binop (PR middle-end/88032)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 16 Nov 2018 09:49:50 +0100
- Subject: [PATCH] Fix expand_binop (PR middle-end/88032)
- References: <f1bbbd7c-df9e-8e30-9037-98703fd4a1a1@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot 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