X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ftree-chrec.c;h=26ae9b408a70a2f9c51f5fe8d15419ea658efa17;hb=bf3e1520c00cff0abcd998aac1c85f084f162d3e;hp=89e96fd53b68aa17b6c9a1fce050997e95ea3f9b;hpb=75a70cf95f65fe9204b15ad9aba31c571381d224;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 89e96fd53b6..26ae9b408a7 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -579,8 +579,7 @@ chrec_apply (unsigned var, /* "{a, +, b} (x)" -> "a + b*x". */ x = chrec_convert_rhs (type, x, NULL); res = chrec_fold_multiply (TREE_TYPE (x), CHREC_RIGHT (chrec), x); - if (!integer_zerop (CHREC_LEFT (chrec))) - res = chrec_fold_plus (type, CHREC_LEFT (chrec), res); + res = chrec_fold_plus (type, CHREC_LEFT (chrec), res); } else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC) @@ -1408,3 +1407,26 @@ scev_direction (const_tree chrec) else return EV_DIR_GROWS; } + +/* Iterates over all the components of SCEV, and calls CBCK. */ + +void +for_each_scev_op (tree *scev, bool (*cbck) (tree *, void *), void *data) +{ + switch (TREE_CODE_LENGTH (TREE_CODE (*scev))) + { + case 3: + for_each_scev_op (&TREE_OPERAND (*scev, 2), cbck, data); + + case 2: + for_each_scev_op (&TREE_OPERAND (*scev, 1), cbck, data); + + case 1: + for_each_scev_op (&TREE_OPERAND (*scev, 0), cbck, data); + + default: + cbck (scev, data); + break; + } +} +