On Fri, Nov 8, 2013 at 5:02 PM, Jeff Law <l...@redhat.com> wrote:
> On 11/08/13 07:45, Steven Bosscher wrote:
>>
>> On Fri, Nov 8, 2013 at 3:40 PM, Joern Rennecke
>> <joern.renne...@embecosm.com> wrote:
>>>
>>> bootstrapped / regtested on i686-pc-linux-gnu.
>>
>>
>> Not a very elaborate description of the patch, eh? :-)
>>
>> This is IMHO not OK without at least an explanation of why the
>> comparison of two const_ints is not folded. Better yet would be to fix
>> that underlying problem. We should not present such non-sense to the
>> RTL parts of the middle end.
> Agreed.

In this case it's fold-all-builtins folding a strlen call with a
PHI <"foo", "bar"> argument.  IMHO not presenting RTL with such
non-sense is best achieved by not letting TER do constant propagation
(because it doesn't "fold" the result).  We can never rule out such
stray non-propagated constants, so that makes expand more robust
(and hopes for RTL CCP).

Index: gcc/tree-ssa-ter.c
===================================================================
--- gcc/tree-ssa-ter.c  (revision 204664)
+++ gcc/tree-ssa-ter.c  (working copy)
@@ -438,6 +439,12 @@ ter_is_replaceable_p (gimple stmt)
          && !is_gimple_val (gimple_assign_rhs1 (stmt)))
        return false;

+      /* Do not propagate "modeless" constants - we may end up
confusing the RTL
+        expanders.  Leave the optimization to RTL CCP.  */
+      if (gimple_assign_single_p (stmt)
+         && CONSTANT_CLASS_P (gimple_assign_rhs1 (stmt)))
+       return false;
+
       return true;
     }
   return false;

does that make sense?  I'll test it then.

Thanks,
Richard.

> jeff
>

Reply via email to