Patchwork RFA: Fix PR middle-end/59049

login
register
mail settings
Submitter Joern Rennecke
Date Nov. 8, 2013, 5:11 p.m.
Message ID <CAMqJFCpZqU=7Hf0q6vL-pLExZXdk8r+m5Wfwit5-Nu2L2WDN8w@mail.gmail.com>
Download mbox | patch
Permalink /patch/289892/
State New
Headers show

Comments

Joern Rennecke - Nov. 8, 2013, 5:11 p.m.
On 8 November 2013 15:50, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Even with the gimple opts disabled, a const-const comparison would
> normally be folded by the RTL expanders.

Well, in this spirit, attached is another way to address the RTL side
of the problem.
As mention in the PR, the tree side of the problem started showing up
in r204194.
2013-11-08  Joern Rennecke  <joern.rennecke@embecosm.com>

	PR middle-end/59049
	* expmed.c (emit_store_flag): Fail for const-const comparison.
Jakub Jelinek - Nov. 11, 2013, 2:40 p.m.
On Fri, Nov 08, 2013 at 05:11:39PM +0000, Joern Rennecke wrote:
> On 8 November 2013 15:50, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> > Even with the gimple opts disabled, a const-const comparison would
> > normally be folded by the RTL expanders.
> 
> Well, in this spirit, attached is another way to address the RTL side
> of the problem.
> As mention in the PR, the tree side of the problem started showing up
> in r204194.

> 2013-11-08  Joern Rennecke  <joern.rennecke@embecosm.com>
> 
> 	PR middle-end/59049
> 	* expmed.c (emit_store_flag): Fail for const-const comparison.

LGTM (I'd just write return NULL_RTX; instead of return 0;).

> --- expmed.c	(revision 204568)
> +++ expmed.c	(working copy)
> @@ -5401,6 +5401,13 @@ emit_store_flag (rtx target, enum rtx_co
>    rtx subtarget;
>    rtx tem, last, trueval;
>  
> +  /* If we compare constants, we shouldn't use a store-flag operation,
> +     but a constant load.  We can get there via the vanilla route that
> +     usually generates a compare-branch sequence, but will in this case
> +     fold the comparison to a constant, and thus elide the branch.  */
> +  if (CONSTANT_P (op0) && CONSTANT_P (op1))
> +    return 0;
> +
>    tem = emit_store_flag_1 (target, code, op0, op1, mode, unsignedp, normalizep,
>  			   target_mode);
>    if (tem)


	Jakub

Patch

Index: expmed.c
===================================================================
--- expmed.c	(revision 204568)
+++ expmed.c	(working copy)
@@ -5401,6 +5401,13 @@  emit_store_flag (rtx target, enum rtx_co
   rtx subtarget;
   rtx tem, last, trueval;
 
+  /* If we compare constants, we shouldn't use a store-flag operation,
+     but a constant load.  We can get there via the vanilla route that
+     usually generates a compare-branch sequence, but will in this case
+     fold the comparison to a constant, and thus elide the branch.  */
+  if (CONSTANT_P (op0) && CONSTANT_P (op1))
+    return 0;
+
   tem = emit_store_flag_1 (target, code, op0, op1, mode, unsignedp, normalizep,
 			   target_mode);
   if (tem)