On Fri, Nov 08, 2013 at 05:11:39PM +0000, Joern Rennecke wrote:
> On 8 November 2013 15:50, Steven Bosscher <stevenb....@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.renne...@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

Reply via email to