commit 9f43be3eed730741c628110fe1c496dec34fddb5 Author: Alexander Monakov Date: Tue Feb 16 21:39:05 2010 +0300 Handle ADDR_EXPR in SCEV 2010-02-17 Alexander Monakov * tree-scalar-evolution.c (interpret_rhs_expr): Handle ADDR_EXPR. diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 4d8f85e..b9f7125 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1720,6 +1720,34 @@ interpret_rhs_expr (struct loop *loop, gimple at_stmt, at_stmt); } + if (code == ADDR_EXPR + && handled_component_p (TREE_OPERAND (rhs1, 0))) + { + HOST_WIDE_INT bitsize, bitpos; + tree toff, base, ref; + enum machine_mode mode; + int uns, vol; + + ref = TREE_OPERAND (rhs1, 0); + base = get_inner_reference (ref, &bitsize, &bitpos, &toff, &mode, + &uns, &vol, false); + if (bitpos % BITS_PER_UNIT == 0) + { + base = build_fold_addr_expr (base); + chrec1 = analyze_scalar_evolution (loop, base); + chrec1 = chrec_convert (type, chrec1, at_stmt); + chrec1 = chrec_fold_plus (type, chrec1, + size_int (bitpos / BITS_PER_UNIT)); + if (toff) + { + chrec2 = analyze_scalar_evolution (loop, toff); + chrec2 = chrec_convert (sizetype, chrec2, at_stmt); + chrec1 = chrec_fold_plus (type, chrec1, chrec2); + } + return chrec1; + } + } + return chrec_dont_know; }