This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Very simple constant propagation (revisited)


Unfortunately, this problem does not exist "at the tree-ssa level". The conversion of "a/b" into
"a * 1/b" does not happen until expansion, when the trees are expanded into RTL. Therefore the
necessary constant propagation cannot happen until after that point. For reference, the relevant code
is in expand_expr_real_1 (expr.c, line 8158):


case RDIV_EXPR:
/* Emit a/b as a*(1/b). Later we may manage CSE the reciprocal saving
expensive divide. If not, combine will rebuild the original
computation. */
if (flag_unsafe_math_optimizations && optimize && !optimize_size
&& TREE_CODE (type) == REAL_TYPE
&& !real_onep (TREE_OPERAND (exp, 0)))
return expand_expr (build (MULT_EXPR, type, TREE_OPERAND (exp, 0),
build (RDIV_EXPR, type,
build_real (type, dconst1),
TREE_OPERAND (exp, 1))),
target, tmode, modifier);



Since this problem cannot be solved at the tree-ssa level, do I have permission to commit my
patch (with Paolo's suggested change)?


-- Caroline Tice
ctice@apple.com

On Mar 2, 2004, at 10:09 PM, Richard Henderson wrote:

On Tue, Mar 02, 2004 at 04:01:56PM -0800, Caroline Tice wrote:
This patch is to address an efficiency problem in gcc. If you compile
the following small loop with -O3 -ffast-math, the optimizer converts
the "a/b" into "a * 1/b", in the hopes of being able to do some further
optimizations. In this case it can't so ideally the combiner should
convert "a * 1/b" back into "a/b".

At this point, I'd really prefer to solve this problem at the tree-ssa level.


r~




On Mar 3, 2004, at 12:09 AM, Bonzini wrote:


If the patch goes in, I would prefer if you added the constant
propagation code to combine_simplify_rtx in combine.c. There is no need
to clutter simplify_binary_operation.


Also, is the replacement a*1/b made in fold-const.c or at expansion
time.

Paolo



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]