This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR63798
- From: VÃclav Zeman <vhaisman at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 10 Nov 2014 13:32:12 +0100
- Subject: Re: [PATCH] Fix PR63798
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1411101054190 dot 374 at zhemvz dot fhfr dot qr>
On 10 November 2014 10:55, Richard Biener wrote:
>
>
> The following patch fixes a latent bug uncovered by stmt folding
> that expansion of FMA_EXPR didn't consider the multiplication
> commutative when looking for feeding negates.
>
> Bootstrap & regtest pending.
>
> Richard.
>
> 2014-11-10 Richard Biener <rguenther@suse.de>
>
> PR middle-end/63798
> * expr.c (expand_expr_real_2): When expanding FMA_EXPRs
> properly treat the embedded multiplication as commutative
> when looking for feeding negates.
>
> Index: gcc/expr.c
> ===================================================================
> --- gcc/expr.c (revision 217281)
> +++ gcc/expr.c (working copy)
> @@ -8621,6 +8621,19 @@ expand_expr_real_2 (sepops ops, rtx targ
> }
>
> def0 = get_def_for_expr (treeop0, NEGATE_EXPR);
> + /* The multiplication is commutative - look at its 2nd operand
> + if the first isn't fed by a negate. */
> + if (!def0)
> + {
> + def0 = get_def_for_expr (treeop1, NEGATE_EXPR);
> + /* Swap operands if the 2nd operand is fed by a negate. */
> + if (def0)
> + {
> + tree tem = treeop0;
> + treeop0 = treeop1;
> + treeop1 = tem;
What about using std::swap() maybe?
> + }
> + }
> def2 = get_def_for_expr (treeop2, NEGATE_EXPR);
>
> op0 = op2 = NULL;
--
VZ