On 07/01/2011 01:58 PM, Stubbs, Andrew wrote:
Given this test case:
    unsigned long long
    foo (unsigned long long a, signed char *b, signed char *c)
    {
      return a + *b * *c;
    }

Those rules say that it should not be suitable for optimization because
there's an implicit cast from signed int to unsigned long long.
Got it now!  Casts from signed to unsigned are not value-preserving, but 
they are "bit-preserving": s32->s64 obviously is, and s32->u64 has the 
same result bit-by-bit as the s64 result.  The fact that s64 has an 
implicit 1111... in front, while an u64 has an implicit 0000... does not 
matter.
Is this the meaning of the predicate you want?  I think so, based on the 
discussion, but it's hard to say without seeing the cases enumerated 
(i.e. a patch).
However, perhaps there is a catch.  We can do the following thought 
experiment.  What would happen if you had multiple widening multiplies? 
 Like 8-bit signed to 64-bit unsigned and then 64-bit unsigned to 
128-bit unsigned?  I believe in this case you couldn't optimize 8-bit 
signed to 128-bit unsigned.  Would your code do it?
Paolo

Reply via email to