[PATCH] simplify_rtx shouldn't modify its argument
Geoff Keating
geoffk@geoffk.org
Thu Jul 17 21:22:00 GMT 2003
Roger Sayle <roger@eyesopen.com> writes:
> The following patch is another step towards unification of GCC's
> RTL simplifiers. The preferred "one", simplify_rtx, is far more
> useful to the rest of the compiler if it doesn't modify its
> argument directly, especially if it then decides to return NULL_RTX
> anyway, providing no warning of the modification to the caller.
>
>
> The following patch has been tested on i686-pc-linux-gnu with a
> complete "make bbotstrap", all languages except treelang, and regression
> tested with a top-level "make -k check" with no new failures.
>
>
> Ok for mainline?
Could you look at the history of this code? It seems odd to me that
it wouldn't have been written this way all along...
> 2003-07-17 Roger Sayle <roger@eyesopen.com>
>
> * simplify-rtx.c (simplify_rtx): Use simplify_gen_binary to swap
> commutative operands instead of modifying the RTL in-place.
>
>
> Index: simplify-rtx.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
> retrieving revision 1.148
> diff -c -3 -p -r1.148 simplify-rtx.c
> *** simplify-rtx.c 16 Jul 2003 19:34:50 -0000 1.148
> --- simplify-rtx.c 17 Jul 2003 12:45:44 -0000
> *************** simplify_rtx (rtx x)
> *** 3048,3062 ****
> XEXP (x, 0), GET_MODE (XEXP (x, 0)));
> case 'c':
> if (swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1)))
> ! {
> ! rtx tem;
>
> ! tem = XEXP (x, 0);
> ! XEXP (x, 0) = XEXP (x, 1);
> ! XEXP (x, 1) = tem;
> ! return simplify_binary_operation (code, mode,
> ! XEXP (x, 0), XEXP (x, 1));
> ! }
>
> case '2':
> return simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x, 1));
> --- 3048,3056 ----
> XEXP (x, 0), GET_MODE (XEXP (x, 0)));
> case 'c':
> if (swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1)))
> ! return simplify_gen_binary (code, mode, XEXP (x, 1), XEXP (x, 0));
>
> ! /* ... fall through ... */
>
> case '2':
> return simplify_binary_operation (code, mode, XEXP (x, 0), XEXP (x, 1));
>
>
> Roger
> --
> Roger Sayle, E-mail: roger@eyesopen.com
> OpenEye Scientific Software, WWW: http://www.eyesopen.com/
> Suite 1107, 3600 Cerrillos Road, Tel: (+1) 505-473-7385
> Santa Fe, New Mexico, 87507. Fax: (+1) 505-473-0833
>
>
--
- Geoffrey Keating <geoffk@geoffk.org>
More information about the Gcc-patches
mailing list