From: Toon Moene <toon@moene.indiv.nluug.nl>
To: Richard Henderson <rth@cygnus.com>
Cc: egcs@cygnus.com
Subject: Re: more on fortran array indexing
Date: Sun, 05 Oct 1997 03:12:00 -0000 [thread overview]
Message-ID: <9710051010.AA02184@moene.indiv.nluug.nl> (raw)
In-Reply-To: <9710041510.AA01646@moene.indiv.nluug.nl>
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)
next prev parent reply other threads:[~1997-10-05 3:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-10-02 13:04 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 [this message]
1997-10-26 9:05 ` Jeffrey A Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9710051010.AA02184@moene.indiv.nluug.nl \
--to=toon@moene.indiv.nluug.nl \
--cc=egcs@cygnus.com \
--cc=rth@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).