This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Miscelaneous ivopts improvements (3 of 3)
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 30 Jan 2005 19:30:17 +0100
- Subject: [patch] Miscelaneous ivopts improvements (3 of 3)
Hello,
the third patch is a fix that prevents us from producing expressions
like i = (int) ((unsigned) i + 1) if not necessary. The produced code
is easier to handle for other optimizers, and there are measurable
speedups for spec. Given the simplicity of the patch, this seems
as a good enough reason for having it in 4.0.
Bootstrapped & regtested on i686.
Zdenek
* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Do not add
unnecessary cast to original induction variable increments.
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.35
diff -c -3 -p -r2.35 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c 7 Dec 2004 21:23:04 -0000 2.35
--- tree-ssa-loop-ivopts.c 15 Dec 2004 01:01:15 -0000
*************** static void
*** 4337,4347 ****
rewrite_use_nonlinear_expr (struct ivopts_data *data,
struct iv_use *use, struct iv_cand *cand)
{
! tree comp = unshare_expr (get_computation (data->current_loop,
! use, cand));
tree op, stmts, tgt, ass;
block_stmt_iterator bsi, pbsi;
!
switch (TREE_CODE (use->stmt))
{
case PHI_NODE:
--- 4390,4421 ----
rewrite_use_nonlinear_expr (struct ivopts_data *data,
struct iv_use *use, struct iv_cand *cand)
{
! tree comp;
tree op, stmts, tgt, ass;
block_stmt_iterator bsi, pbsi;
!
! /* An important special case -- if we are asked to express value of
! the original iv by itself, just exit; there is no need to
! introduce a new computation (that might also need casting the
! variable to unsigned and back). */
! if (cand->pos == IP_ORIGINAL
! && TREE_CODE (use->stmt) == MODIFY_EXPR
! && TREE_OPERAND (use->stmt, 0) == cand->var_after)
! {
! op = TREE_OPERAND (use->stmt, 1);
!
! /* Be a bit careful. In case variable is expressed in some
! complicated way, rewrite it so that we may get rid of this
! complicated expression. */
! if ((TREE_CODE (op) == PLUS_EXPR
! || TREE_CODE (op) == MINUS_EXPR)
! && TREE_OPERAND (op, 0) == cand->var_before
! && TREE_CODE (TREE_OPERAND (op, 1)) == INTEGER_CST)
! return;
! }
!
! comp = unshare_expr (get_computation (data->current_loop,
! use, cand));
switch (TREE_CODE (use->stmt))
{
case PHI_NODE: