This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Revision 107218 changed addressing mode generation
Richard Guenther wrote:
I think CSE added/removed by either canoncial form is less important
than things like SCEV analysis being unaffected and IVOPTs still
creating proper induction variables on the tree level.
Of course a canonical form should minimize the number of operations,
so folding i * 4 + j * 4 to (i + j) * 4 should still be done. But
folding i * 4 + j * 2 to (i * 2 + j) * 2 and not i * 4 + 4 to (i + 1) * 4
looks strange.
I have been resistant to change this canonicalization simply because
the current one seems to work well with the tree loop optimizers and
date-dependence analysis nowadays, thus also my hint at doing
such change during stage1 instead of stage4 (after all this "problem"
now exists since 4.1 ...?)
Implementing the change should be straight-forward (we should
make sure the tree reassociation pass agrees with it).
So, how do we proceed? IMO the canonical form should be that addition
of a constant is always the outermost operation. That seems to be what
the EXPAND_SUM machinery expects, and what extract_muldiv wants to do.
It's also IMO most likely to be helpful when generating addressing modes.
The patch below should do that, but unfortunately:
+FAIL: gcc.dg/vect/vect-103.c scan-tree-dump-times vect "dependence
distance modulo vf == 0" 1
+FAIL: gcc.dg/vect/no-vfa-vect-102.c scan-tree-dump-times vect "possible
dependence between data-refs" 1
I'm not really familiar with the vectorizer.
Still - would someone like to benchmark this patch on i686-linux, maybe
with a SPEC run? I don't have that available.
Bernd
--
This footer brought to you by insane German lawmakers.
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 40368
Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif
* fold-const.c (fold_plusminus_mult_expr): Return NULL_TREE if either
argument is an INTEGER_CST.
Index: fold-const.c
===================================================================
--- fold-const.c (revision 145077)
+++ fold-const.c (working copy)
@@ -7403,6 +7403,9 @@ fold_plusminus_mult_expr (enum tree_code
tree arg00, arg01, arg10, arg11;
tree alt0 = NULL_TREE, alt1 = NULL_TREE, same;
+ if (TREE_CODE (arg0) == INTEGER_CST || TREE_CODE (arg1) == INTEGER_CST)
+ return NULL_TREE;
+
/* (A * C) +- (B * C) -> (A+-B) * C.
(A * C) +- A -> A * (C+-1).
We are most concerned about the case where C is a constant,
@@ -7414,11 +7417,6 @@ fold_plusminus_mult_expr (enum tree_code
arg00 = TREE_OPERAND (arg0, 0);
arg01 = TREE_OPERAND (arg0, 1);
}
- else if (TREE_CODE (arg0) == INTEGER_CST)
- {
- arg00 = build_one_cst (type);
- arg01 = arg0;
- }
else
{
/* We cannot generate constant 1 for fract. */
@@ -7427,26 +7425,12 @@ fold_plusminus_mult_expr (enum tree_code
arg00 = arg0;
arg01 = build_one_cst (type);
}
+
if (TREE_CODE (arg1) == MULT_EXPR)
{
arg10 = TREE_OPERAND (arg1, 0);
arg11 = TREE_OPERAND (arg1, 1);
}
- else if (TREE_CODE (arg1) == INTEGER_CST)
- {
- arg10 = build_one_cst (type);
- /* As we canonicalize A - 2 to A + -2 get rid of that sign for
- the purpose of this canonicalization. */
- if (TREE_INT_CST_HIGH (arg1) == -1
- && negate_expr_p (arg1)
- && code == PLUS_EXPR)
- {
- arg11 = negate_expr (arg1);
- code = MINUS_EXPR;
- }
- else
- arg11 = arg1;
- }
else
{
/* We cannot generate constant 1 for fract. */