* more on fortran array indexing @ 1997-10-02 13:04 Richard Henderson 1997-10-03 1:33 ` Toon Moene 0 siblings, 1 reply; 6+ messages in thread From: Richard Henderson @ 1997-10-02 13:04 UTC (permalink / raw) To: egcs Last night I examined the differences in the output of the friendlier FASTER_ARRAY_REFS, and the patched expr.c ARRAY_REF. They output, respectively, addr = ((n*64)/8 * (j-1)) + (i*8) + base - 8 and addr = (i-1)*8 + ((j-1) * (n*64)) / 8 + base IMO, it is obviously the FLOOR_DIV 8 that is causing the problem. Question: Why in the world are arrays indexed as bits? There seems to me to be very little use for such a thing, and a front end that would need it could build it out of simpler constructs, no? Or perhaps add a flag to TYPE to indicate whether the array is indexed via bytes or bits to get rid of this lossage where it isn't needed. Note that even in the FASTER_ARRAY_REFS case, there is still the divide in the asm output -- we were able to reduce it out of the loop, but not eliminate it. Comments? r~ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: more on fortran array indexing 1997-10-02 13:04 more on fortran array indexing Richard Henderson @ 1997-10-03 1:33 ` Toon Moene 1997-10-03 11:05 ` Richard Henderson 1997-10-26 9:05 ` Jeffrey A Law 0 siblings, 2 replies; 6+ messages in thread From: Toon Moene @ 1997-10-03 1:33 UTC (permalink / raw) To: Richard Henderson; +Cc: egcs > Last night I examined the differences in the output of > the friendlier FASTER_ARRAY_REFS, and the patched expr.c > ARRAY_REF. > > They output, respectively, > > addr = ((n*64)/8 * (j-1)) + (i*8) + base - 8 > > and > > addr = (i-1)*8 + ((j-1) * (n*64)) / 8 + base > > IMO, it is obviously the FLOOR_DIV 8 that is causing the > problem. Please try the following patch: * fold-const (fold): Also simplify FLOOR_DIV_EXPR iff dividend is a multiple of divisor *** egcs-970929/gcc/fold-const.c.orig Fri Oct 3 10:07:37 1997 --- egcs-970929/gcc/fold-const.c Fri Oct 3 10:09:53 1997 *************** fold (expr) *** 4611,4619 **** operation, EXACT_DIV_EXPR. ! Note that only CEIL_DIV_EXPR is rewritten now, only because the ! others seem to be faster in some cases. This is probably just ! due to more work being done to optimize others in expmed.c than on ! EXACT_DIV_EXPR. */ ! if (code == CEIL_DIV_EXPR && multiple_of_p (type, arg0, arg1)) return fold (build (EXACT_DIV_EXPR, type, arg0, arg1)); --- 4611,4619 ---- operation, EXACT_DIV_EXPR. ! Note that only CEIL_DIV_EXPR and FLOOR_DIV_EXPR are rewritten now, ! only because the others seem to be faster in some cases. ! This is probably just due to more work being done to optimize ! others in expmed.c than on EXACT_DIV_EXPR. */ ! if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR) && multiple_of_p (type, arg0, arg1)) return fold (build (EXACT_DIV_EXPR, type, arg0, arg1)); Cheers, Toon. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: more on fortran array indexing 1997-10-03 1:33 ` Toon Moene @ 1997-10-03 11:05 ` Richard Henderson 1997-10-04 8:12 ` Toon Moene 1997-10-26 9:05 ` Jeffrey A Law 1 sibling, 1 reply; 6+ messages in thread From: Richard Henderson @ 1997-10-03 11:05 UTC (permalink / raw) To: Toon Moene; +Cc: Richard Henderson, egcs > Please try the following patch: > > * fold-const (fold): Also simplify FLOOR_DIV_EXPR > iff dividend is a multiple of divisor No good. The problem being, I believe, that n*64 is wrapped in a save_expr, and so we can't get rid of it. I'd actually already tried making the ARRAY_REF expansion use EXACT_DIV_EXPR.. r~ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: more on fortran array indexing 1997-10-03 11:05 ` Richard Henderson @ 1997-10-04 8:12 ` Toon Moene 1997-10-05 3:12 ` Toon Moene 0 siblings, 1 reply; 6+ messages in thread From: Toon Moene @ 1997-10-04 8:12 UTC (permalink / raw) To: Richard Henderson; +Cc: egcs I wrote: >> Please try the following patch: >> >> * fold-const (fold): Also simplify FLOOR_DIV_EXPR >> iff dividend is a multiple of divisor Richard: > No good. The problem being, I believe, that n*64 is > wrapped in a save_expr, and so we can't get rid of it. > I'd actually already tried making the ARRAY_REF expansion > use EXACT_DIV_EXPR.. After some testing, I'm less and less convinced that this is the problem. There are still "subreg ... sign_extend"'s lying around in the -dL (resid.f.loop) output, which means that there are "unnecessary" conversions being done. Note that fold-const.c knows how to get rid of divisions within SAVE_EXPR's (at least in principle). IMHO, there's nothing wrong with the division. Unfortunately, I haven't been able to track the real problem down. Cheers, Toon. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: more on fortran array indexing 1997-10-04 8:12 ` Toon Moene @ 1997-10-05 3:12 ` Toon Moene 0 siblings, 0 replies; 6+ messages in thread From: Toon Moene @ 1997-10-05 3:12 UTC (permalink / raw) To: Richard Henderson; +Cc: egcs Yesterday, I wrote: > Note that fold-const.c knows how to get rid of divisions > within SAVE_EXPR's (at least in principle). > > IMHO, there's nothing wrong with the division. This, however is not entirely true. The only way to get completely rid of all remnants of the FLOOR_DIV_EXPR (srl's and such) is the following patch (which I had already applied): The first part makes gcc deal with FLOOR_DIV_EXPR the way it deals with CEIL_DIV_EXPR in expressions where there is a multiple of the divisor in the dividend. The second part makes up for the fact that fold() doesn't seem to look "into" subexpressions of the dividend. HTH, Toon. PS: Although this leads to better code, it still doesn't solve the real problem, namely the conversions between the index type and `sizetype'. *** egcs-970929/gcc/fold-const.c.orig Fri Oct 3 10:07:37 1997 --- egcs-970929/gcc/fold-const.c Sat Oct 4 13:18:29 1997 *************** fold (expr) *** 4611,4619 **** operation, EXACT_DIV_EXPR. ! Note that only CEIL_DIV_EXPR is rewritten now, only because the ! others seem to be faster in some cases. This is probably just ! due to more work being done to optimize others in expmed.c than on ! EXACT_DIV_EXPR. */ ! if (code == CEIL_DIV_EXPR && multiple_of_p (type, arg0, arg1)) return fold (build (EXACT_DIV_EXPR, type, arg0, arg1)); --- 4611,4619 ---- operation, EXACT_DIV_EXPR. ! Note that only CEIL_DIV_EXPR and FLOOR_DIV_EXPR are rewritten now, ! only because the others seem to be faster in some cases. ! This is probably just due to more work being done to optimize ! others in expmed.c than on EXACT_DIV_EXPR. */ ! if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR) && multiple_of_p (type, arg0, arg1)) return fold (build (EXACT_DIV_EXPR, type, arg0, arg1)); *************** fold (expr) *** 4657,4660 **** --- 4657,4680 ---- STRIP_NOPS (xarg0); + if (TREE_CODE (xarg0) == MULT_EXPR + && multiple_of_p (type, TREE_OPERAND (xarg0, 0), arg1)) + { + return fold (build (MULT_EXPR, type, + fold (build (EXACT_DIV_EXPR, type, + TREE_OPERAND (xarg0, 0), + arg1)), + TREE_OPERAND (xarg0, 1))); + } + + if (TREE_CODE (xarg0) == MULT_EXPR + && multiple_of_p (Ttype, REE_OPERAND (xarg0, 1), arg1)) + { + return fold (build (MULT_EXPR, type, + fold (build (EXACT_DIV_EXPR, type, + TREE_OPERAND (xarg0, 1), + arg1)), + TREE_OPERAND (xarg0, 0))); + } + if (TREE_CODE (xarg0) == PLUS_EXPR && TREE_CODE (TREE_OPERAND (xarg0, 1)) == INTEGER_CST) ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: more on fortran array indexing 1997-10-03 1:33 ` Toon Moene 1997-10-03 11:05 ` Richard Henderson @ 1997-10-26 9:05 ` Jeffrey A Law 1 sibling, 0 replies; 6+ messages in thread From: Jeffrey A Law @ 1997-10-26 9:05 UTC (permalink / raw) To: Toon Moene; +Cc: Richard Henderson, egcs In message < 9710030816.AA26550@moene.indiv.nluug.nl >you write: > Please try the following patch: > > * fold-const (fold): Also simplify FLOOR_DIV_EXPR > iff dividend is a multiple of divisor Installed. jeff ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1997-10-26 9:05 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1997-10-02 13:04 more on fortran array indexing Richard Henderson 1997-10-03 1:33 ` Toon Moene 1997-10-03 11:05 ` Richard Henderson 1997-10-04 8:12 ` Toon Moene 1997-10-05 3:12 ` Toon Moene 1997-10-26 9:05 ` Jeffrey A Law
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).