This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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  <dberlin@dberlin.org>

        * 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
<richard.guenther@gmail.com> wrote:
> On Sat, Oct 18, 2008 at 7:19 PM, Daniel Berlin <dberlin@dberlin.org> wrote:
>> On Sat, Oct 18, 2008 at 6:27 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Sat, Oct 18, 2008 at 4:02 AM, Daniel Berlin <dberlin@dberlin.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 ...
>
> Richard.
>
>>>
>>
>
Index: tree-ssa-pre.c
===================================================================
--- 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;
-		}
-	      else
+	      if (!is_gimple_min_invariant (builtexpr)) 
 		{
 		  tree forcedexpr = force_gimple_operand (builtexpr,
 							  &stmts, true,
 							  NULL);
-		  if (is_gimple_min_invariant (forcedexpr))
-		    {
-		      PRE_EXPR_CONSTANT (eprime) = forcedexpr;
-		    }
-		  else
+		  if (!is_gimple_min_invariant (forcedexpr))
 		    {
 		      if (forcedexpr != builtexpr)
 			{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]