public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix emit_conditional_move (PR target/84860)
@ 2018-03-14 22:35 Jakub Jelinek
  2018-03-15  8:27 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2018-03-14 22:35 UTC (permalink / raw)
  To: Richard Biener, Jeff Law; +Cc: gcc-patches

Hi!

prepare_cmp_insn in some cases changes both the passed in comparison and the
comparison mode, e.g. by promoting the arguments from SFmode to DFmode etc.

In emit_conditional_move we call this in a loop, for (pass = 0; pass < 2; pass++)
and in each case construct comparison arguments as well as the comparison
passed to it from the original arguments (we have to after all, because when
not successful, we throw the whole insn sequence away), but use cmode which
the first iteration could have changed, on this testcase on powerpcspe with
-mcpu=8548 from SFmode to DFmode, so we ICE the second time, because the
arguments don't really match the comparison mode.

Fixed by passing it an address of a copy of the cmode parameter, so that the
second pass starts with the original cmode that matches the arguments again.

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

2018-03-14  Jakub Jelinek  <jakub@redhat.com>

	PR target/84860
	* optabs.c (emit_conditional_move): Pass address of cmode's copy
	rather than address of cmode as last argument to prepare_cmp_insn.

	* gcc.c-torture/compile/pr84860.c: New test.

--- gcc/optabs.c.jj	2018-02-09 19:11:29.000000000 +0100
+++ gcc/optabs.c	2018-03-14 09:22:31.707873477 +0100
@@ -4345,9 +4345,10 @@ emit_conditional_move (rtx target, enum
 	  save_pending_stack_adjust (&save);
 	  last = get_last_insn ();
 	  do_pending_stack_adjust ();
+	  machine_mode cmpmode = cmode;
 	  prepare_cmp_insn (XEXP (comparison, 0), XEXP (comparison, 1),
 			    GET_CODE (comparison), NULL_RTX, unsignedp,
-			    OPTAB_WIDEN, &comparison, &cmode);
+			    OPTAB_WIDEN, &comparison, &cmpmode);
 	  if (comparison)
 	    {
 	      struct expand_operand ops[4];
--- gcc/testsuite/gcc.c-torture/compile/pr84860.c.jj	2018-03-14 09:26:19.988883506 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr84860.c	2018-03-14 09:26:44.854884590 +0100
@@ -0,0 +1,11 @@
+/* PR target/84860 */
+
+void
+foo (int x, int y)
+{
+  while (x < 1)
+    {
+      x = y;
+      y = ((float)1 / 0) ? 2 : 0;
+    }
+}

	Jakub

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

* Re: [PATCH] Fix emit_conditional_move (PR target/84860)
  2018-03-14 22:35 [PATCH] Fix emit_conditional_move (PR target/84860) Jakub Jelinek
@ 2018-03-15  8:27 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2018-03-15  8:27 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jeff Law, gcc-patches

On Wed, 14 Mar 2018, Jakub Jelinek wrote:

> Hi!
> 
> prepare_cmp_insn in some cases changes both the passed in comparison and the
> comparison mode, e.g. by promoting the arguments from SFmode to DFmode etc.
> 
> In emit_conditional_move we call this in a loop, for (pass = 0; pass < 2; pass++)
> and in each case construct comparison arguments as well as the comparison
> passed to it from the original arguments (we have to after all, because when
> not successful, we throw the whole insn sequence away), but use cmode which
> the first iteration could have changed, on this testcase on powerpcspe with
> -mcpu=8548 from SFmode to DFmode, so we ICE the second time, because the
> arguments don't really match the comparison mode.
> 
> Fixed by passing it an address of a copy of the cmode parameter, so that the
> second pass starts with the original cmode that matches the arguments again.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Richard.

> 2018-03-14  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR target/84860
> 	* optabs.c (emit_conditional_move): Pass address of cmode's copy
> 	rather than address of cmode as last argument to prepare_cmp_insn.
> 
> 	* gcc.c-torture/compile/pr84860.c: New test.
> 
> --- gcc/optabs.c.jj	2018-02-09 19:11:29.000000000 +0100
> +++ gcc/optabs.c	2018-03-14 09:22:31.707873477 +0100
> @@ -4345,9 +4345,10 @@ emit_conditional_move (rtx target, enum
>  	  save_pending_stack_adjust (&save);
>  	  last = get_last_insn ();
>  	  do_pending_stack_adjust ();
> +	  machine_mode cmpmode = cmode;
>  	  prepare_cmp_insn (XEXP (comparison, 0), XEXP (comparison, 1),
>  			    GET_CODE (comparison), NULL_RTX, unsignedp,
> -			    OPTAB_WIDEN, &comparison, &cmode);
> +			    OPTAB_WIDEN, &comparison, &cmpmode);
>  	  if (comparison)
>  	    {
>  	      struct expand_operand ops[4];
> --- gcc/testsuite/gcc.c-torture/compile/pr84860.c.jj	2018-03-14 09:26:19.988883506 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr84860.c	2018-03-14 09:26:44.854884590 +0100
> @@ -0,0 +1,11 @@
> +/* PR target/84860 */
> +
> +void
> +foo (int x, int y)
> +{
> +  while (x < 1)
> +    {
> +      x = y;
> +      y = ((float)1 / 0) ? 2 : 0;
> +    }
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)

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

end of thread, other threads:[~2018-03-15  8:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 22:35 [PATCH] Fix emit_conditional_move (PR target/84860) Jakub Jelinek
2018-03-15  8:27 ` Richard Biener

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