This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH]: Fix missed PRE optimization discovered
After bootstrapping and regtesting the variant Richard requested, here
is what i am checking in:
2008-10-20 Daniel Berlin <email@example.com>
* tree-ssa-pre.c (insert_into_preds_of_block): Don't rewrite constant
part of expression.
Sorry about the delay
On Sat, Oct 18, 2008 at 1:51 PM, Richard Guenther
> On Sat, Oct 18, 2008 at 7:19 PM, Daniel Berlin <firstname.lastname@example.org> wrote:
>> On Sat, Oct 18, 2008 at 6:27 AM, Richard Guenther
>> <email@example.com> wrote:
>>> On Sat, Oct 18, 2008 at 4:02 AM, Daniel Berlin <firstname.lastname@example.org> wrote:
>>>> I'm currently testing the following, which at least doesn't crash on
>>>> the minimized testcase i produced :)
>>> Looking at that patch I wonder if
>>> - if (TREE_TYPE (constant) != type)
>>> + if (!useless_type_conversion_p (type, TREE_TYPE (constant)))
>>> will also work.
>> Probably, but we really shouldn't just willy nilly replace one with
>> the other anyway. :)
>> If you like, i can try both :)
> Yes please ;)
>> At worst what is going to happen is that we will call fold_convert a
>> few more times than necessary, and in very strange cases (where
>> converting one constant to the other requires a real conversion),
>> create a small amount of necessary code.
> Well, IMHO every time we hit this type-not-compatible case there should
> be a bug elsewhere ...
--- tree-ssa-pre.c (revision 141195)
+++ tree-ssa-pre.c (working copy)
@@ -3019,23 +3019,15 @@ insert_into_preds_of_block (basic_block
should give us back a constant with the right type.
tree constant = PRE_EXPR_CONSTANT (eprime);
- if (TREE_TYPE (constant) != type)
+ if (!useless_type_conversion_p (type, TREE_TYPE (constant)))
tree builtexpr = fold_convert (type, constant);
- if (is_gimple_min_invariant (builtexpr))
- PRE_EXPR_CONSTANT (eprime) = builtexpr;
+ if (!is_gimple_min_invariant (builtexpr))
tree forcedexpr = force_gimple_operand (builtexpr,
- if (is_gimple_min_invariant (forcedexpr))
- PRE_EXPR_CONSTANT (eprime) = forcedexpr;
+ if (!is_gimple_min_invariant (forcedexpr))
if (forcedexpr != builtexpr)