* [PATCH] Properly build integer constants
@ 2011-04-22 19:48 Richard Guenther
2011-04-22 20:08 ` Jakub Jelinek
2011-04-24 21:17 ` H.J. Lu
0 siblings, 2 replies; 4+ messages in thread
From: Richard Guenther @ 2011-04-22 19:48 UTC (permalink / raw)
To: gcc-patches
There is a scary comment before build_int_cst_type why build_int_cst
can't be sane. Fortunately it is not true. If it were there would
be other code to be fixed.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2011-04-22 Richard Guenther <rguenther@suse.de>
* tree.c (build_int_cst): Properly create canonicalized integer
constants.
(build_int_cst_type): Remove scary comments.
Index: gcc/tree.c
===================================================================
--- gcc/tree.c (revision 172832)
+++ gcc/tree.c (working copy)
@@ -1004,7 +1004,7 @@ copy_list (tree list)
}
\f
-/* Create an INT_CST node with a LOW value sign extended. */
+/* Create an INT_CST node with a LOW value sign extended to TYPE. */
tree
build_int_cst (tree type, HOST_WIDE_INT low)
@@ -1013,17 +1013,10 @@ build_int_cst (tree type, HOST_WIDE_INT
if (!type)
type = integer_type_node;
- return build_int_cst_wide (type, low, low < 0 ? -1 : 0);
+ return double_int_to_tree (type, shwi_to_double_int (low));
}
-/* Create an INT_CST node with a LOW value in TYPE. The value is sign extended
- if it is negative. This function is similar to build_int_cst, but
- the extra bits outside of the type precision are cleared. Constants
- with these extra bits may confuse the fold so that it detects overflows
- even in cases when they do not occur, and in general should be avoided.
- We cannot however make this a default behavior of build_int_cst without
- more intrusive changes, since there are parts of gcc that rely on the extra
- precision of the integer constants. */
+/* Create an INT_CST node with a LOW value sign extended to TYPE. */
tree
build_int_cst_type (tree type, HOST_WIDE_INT low)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Properly build integer constants
2011-04-22 19:48 [PATCH] Properly build integer constants Richard Guenther
@ 2011-04-22 20:08 ` Jakub Jelinek
2011-04-24 21:17 ` H.J. Lu
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2011-04-22 20:08 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
On Fri, Apr 22, 2011 at 09:27:50PM +0200, Richard Guenther wrote:
> There is a scary comment before build_int_cst_type why build_int_cst
> can't be sane. Fortunately it is not true. If it were there would
> be other code to be fixed.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02297.html
suggests that at least back then the old semantics of build_int_cst
was needed in round_up and build_prim_array_type.
> 2011-04-22 Richard Guenther <rguenther@suse.de>
>
> * tree.c (build_int_cst): Properly create canonicalized integer
> constants.
> (build_int_cst_type): Remove scary comments.
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Properly build integer constants
2011-04-22 19:48 [PATCH] Properly build integer constants Richard Guenther
2011-04-22 20:08 ` Jakub Jelinek
@ 2011-04-24 21:17 ` H.J. Lu
2011-05-03 3:08 ` H.J. Lu
1 sibling, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2011-04-24 21:17 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
On Fri, Apr 22, 2011 at 12:27 PM, Richard Guenther <rguenther@suse.de> wrote:
>
> There is a scary comment before build_int_cst_type why build_int_cst
> can't be sane. Fortunately it is not true. If it were there would
> be other code to be fixed.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>
> Richard.
>
> 2011-04-22 Richard Guenther <rguenther@suse.de>
>
> * tree.c (build_int_cst): Properly create canonicalized integer
> constants.
> (build_int_cst_type): Remove scary comments.
>
This caused:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48753
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Properly build integer constants
2011-04-24 21:17 ` H.J. Lu
@ 2011-05-03 3:08 ` H.J. Lu
0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2011-05-03 3:08 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
On Sun, Apr 24, 2011 at 8:11 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Apr 22, 2011 at 12:27 PM, Richard Guenther <rguenther@suse.de> wrote:
>>
>> There is a scary comment before build_int_cst_type why build_int_cst
>> can't be sane. Fortunately it is not true. If it were there would
>> be other code to be fixed.
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>>
>> Richard.
>>
>> 2011-04-22 Richard Guenther <rguenther@suse.de>
>>
>> * tree.c (build_int_cst): Properly create canonicalized integer
>> constants.
>> (build_int_cst_type): Remove scary comments.
>>
>
> This caused:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48753
>
This also caused:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48846
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-03 3:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-22 19:48 [PATCH] Properly build integer constants Richard Guenther
2011-04-22 20:08 ` Jakub Jelinek
2011-04-24 21:17 ` H.J. Lu
2011-05-03 3:08 ` H.J. Lu
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).