From: Diego Novillo <dnovillo@redhat.com>
To: Roger Sayle <roger@eyesopen.com>
Cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>, Richard Henderson <rth@redhat.com>
Subject: Re: Is this a bug in the folder?
Date: Wed, 22 Sep 2004 08:45:00 -0000 [thread overview]
Message-ID: <1095816076.11068.107.camel@localhost.localdomain> (raw)
In-Reply-To: <Pine.LNX.4.44.0409210906290.20106-100000@www.eyesopen.com>
On Tue, 2004-09-21 at 11:27, Roger Sayle wrote:
> (1) Check that TREE_CODE (TREE_TYPE (tem)) == INTEGER_TYPE after
> the assignment of tem.
>
> (2) Check that TREE_CODE (TREE_TYPE (tem)) == INTEGER_TYPE in
> the final condition immediately before the call to int_fits_type_p.
>
> or slightly more effort
>
> (3) Fix get_unwidened such that t1 is a VECTOR_CST of the approriate
> type and not an INTEGER_CST. Unfortunately, fold_convert doesn't
> yet know how to convert an integer_cst into a vector_cst for values
> other than zero, however it would be useful functionality to have.
> See http://gcc.gnu.org/ml/gcc-patches/2004-09/msg00773.html
>
> I suspect (2) is the safest short term solution to get your code working,
> but ultimately (3) [and the reciprocal vector_cst to integer_cst] would
> allow for better optimizations, for example, to enable constant folding
> of your example comparison at compile-time.
>
I went with #2 in the interest of minimal intrusion for 4.0. The fix to
fold() allowed me to simplify the folding of COND_EXPR predicates
without all the twisty logic we had before.
OK for mainline? (no new tests are necessary, the second part of the
patch produces 3 new failures in gcc.c-torture without the fold patch).
Thanks. Diego.
2004-09-21 Diego Novillo <dnovillo@redhat.com>
* fold-const.c (fold): Avoid non INTEGER_TYPEs when widening
operands in an integer comparison.
* tree-cfg.c (find_taken_edge): Call fold() to determine
whether the predicate is known.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.461
diff -d -c -p -u -r1.461 fold-const.c
--- fold-const.c 17 Sep 2004 21:54:32 -0000 1.461
+++ fold-const.c 22 Sep 2004 01:11:30 -0000
@@ -8290,6 +8290,7 @@ fold (tree expr)
&& (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0
&& (TREE_TYPE (t1) == TREE_TYPE (tem)
|| (TREE_CODE (t1) == INTEGER_CST
+ && TREE_CODE (TREE_TYPE (tem)) == INTEGER_TYPE
&& int_fits_type_p (t1, TREE_TYPE (tem)))))
return fold (build2 (code, type, tem,
fold_convert (TREE_TYPE (tem), t1)));
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.56
diff -d -c -p -u -r2.56 tree-cfg.c
--- tree-cfg.c 18 Sep 2004 21:54:53 -0000 2.56
+++ tree-cfg.c 22 Sep 2004 01:11:30 -0000
@@ -2001,22 +2001,9 @@ find_taken_edge (basic_block bb, tree va
gcc_assert (is_ctrl_stmt (stmt));
/* If VAL is a predicate of the form N RELOP N, where N is an
- SSA_NAME, we can always determine its truth value (except when
- doing floating point comparisons that may involve NaNs). */
- if (val
- && COMPARISON_CLASS_P (val)
- && TREE_OPERAND (val, 0) == TREE_OPERAND (val, 1)
- && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME
- && (TREE_CODE (TREE_TYPE (TREE_OPERAND (val, 0))) != REAL_TYPE
- || !HONOR_NANS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (val, 0))))))
- {
- enum tree_code code = TREE_CODE (val);
-
- if (code == EQ_EXPR || code == LE_EXPR || code == GE_EXPR)
- val = boolean_true_node;
- else if (code == LT_EXPR || code == GT_EXPR || code == NE_EXPR)
- val = boolean_false_node;
- }
+ SSA_NAME, we can usually determine its truth value. */
+ if (val && COMPARISON_CLASS_P (val))
+ val = fold (val);
/* If VAL is not a constant, we can't determine which edge might
be taken. */
prev parent reply other threads:[~2004-09-22 1:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-21 15:55 Diego Novillo
2004-09-21 18:26 ` Roger Sayle
2004-09-22 8:45 ` Diego Novillo [this message]
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=1095816076.11068.107.camel@localhost.localdomain \
--to=dnovillo@redhat.com \
--cc=gcc@gcc.gnu.org \
--cc=roger@eyesopen.com \
--cc=rth@redhat.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).