* [PATCH] Support multiple BOOLEAN_TYPEs in fold
@ 2005-02-19 1:01 Roger Sayle
2005-02-19 1:41 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Roger Sayle @ 2005-02-19 1:01 UTC (permalink / raw)
To: gcc-patches
The following patch improves the middle-end's support for front-ends
with multiple Boolean types. Currently, this only affects gfortran
which has LOGICAL*1, LOGICAL*2, LOGICAL*4, etc... All of GCC's other
front-ends typically have a single Boolean type, boolean_type_node,
which explains the potential bug below, where Boolean constants are
always mapped to the default Boolean type (via the truthvalue_conversion
language hook), not necessarily the specified Boolean type.
For most languages, C/C++/Java/Ada, we no longer call this language
hook, as the earlier "if (type == boolean_type_node)" now catches this
for us. For Ada, this is a good thing, as gnat_truthvalue_conversion
wouldn't convert the integer_one_node/integer_zero_node argument to
any BOOLEAN_TYPE(!). With this change, constant_boolean_node is
now guaranteed to return a tree of the type specified by its type
argument.
The code to call truthvalue_conversion goes all the way back to 1998,
when front-ends probably only had a single BOOLEAN_TYPE. The micro
optimization to check the common case of boolean_type_node, is much
more recent.
The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.
Any objections for mainline?
2005-02-18 Roger Sayle <roger@eyesopen.com>
* fold.c (constant_boolean_node): Always create values of the
specified type, don't bother calling truthvalue_conversion.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.514
diff -c -3 -p -r1.514 fold-const.c
*** fold-const.c 17 Feb 2005 03:03:32 -0000 1.514
--- fold-const.c 18 Feb 2005 04:57:50 -0000
*************** constant_boolean_node (int value, tree t
*** 5381,5389 ****
return value ? integer_one_node : integer_zero_node;
else if (type == boolean_type_node)
return value ? boolean_true_node : boolean_false_node;
- else if (TREE_CODE (type) == BOOLEAN_TYPE)
- return lang_hooks.truthvalue_conversion (value ? integer_one_node
- : integer_zero_node);
else
return build_int_cst (type, value);
}
--- 5381,5386 ----
Roger
--
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Support multiple BOOLEAN_TYPEs in fold
2005-02-19 1:01 [PATCH] Support multiple BOOLEAN_TYPEs in fold Roger Sayle
@ 2005-02-19 1:41 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2005-02-19 1:41 UTC (permalink / raw)
To: Roger Sayle; +Cc: gcc-patches
On Fri, Feb 18, 2005 at 01:35:21PM -0700, Roger Sayle wrote:
> * fold.c (constant_boolean_node): Always create values of the
> specified type, don't bother calling truthvalue_conversion.
Ok.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-02-18 21:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-19 1:01 [PATCH] Support multiple BOOLEAN_TYPEs in fold Roger Sayle
2005-02-19 1:41 ` Richard Henderson
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).