[patch, fortran] Fix PR 42131, improvement in do loops
Daniel Kraft
d@domob.eu
Mon Nov 30 22:50:00 GMT 2009
Thomas Koenig wrote:
> Hello world,
>
> this fixes PR 42131 by using an alternative method of calculating
> the count for non-obvious DO loops. This means that loops with strides
> unknown at compile-time can be unrolled. Just in time for the stage4
> deadline :-)
>
> Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
Ok (after clearing my mind with regard to the question below), thanks
for working on this!
I'm just curious about this:
+ tmp = fold_build2 (RSHIFT_EXPR, type, step,
+ build_int_cst (type,
+ TYPE_PRECISION (type) - 1));
+
+ tmp = fold_build2 (MULT_EXPR, type, tmp,
+ build_int_cst (type, 2));
+
+ step_sign = fold_build2 (PLUS_EXPR, type, tmp,
+ fold_convert (type, integer_one_node));
How does this calculate the sign of step? To me this looks like:
1) Shift step right so that afterwards only the highest bit (which
contains its sign) is present any longer; thus step will be 0 or 1.
2) Multiply it by two, gives 0 or 2. (Why no left-shift?)
3) Add 1, gives 1 or 3 (?).
What am I missing here? (I'm no trans* expert...)
Yours,
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri
More information about the Fortran
mailing list