Hi,

I'm working on compiler for an architecture with a multiply instruction that
takes two 32-bit factors, sign-extends both factors to 64-bits and then does a 
64-bit multiplication and stores the result to a destination register.  The 
combine pass successfully generates the pattern (mulhizi3) for this instruction 
twice for the following function.


    long long res0;
    long long res1;
    
    long f1(long a, long b, long c, long d) {
      res0=((long long) a)*((long long) b);
      res1=((long long) c)*((long long) d);
    }

The generated RTL from combine looks like:

    (insn 10 9 11 2 g.c:5 (set (reg:ZI 176)
            (mult:ZI (sign_extend:ZI (reg:HI 9 r6 [ b ]))
               (sign_extend:ZI (reg:HI 6 r4 [ a ])))) 262 {*mulhizi3} (nil))

However, if I modify the function so that one of the factors is reused,
    
    long f1(long a, long b, long c) {
      res0=((long long) a)*((long long) b);
      res1=((long long) c)*((long long) b);
    }

combine will not fuse the reused sign-extension result to generate the
mulhizi3 pattern.  

I am wondering if anyone else has hit this issue or if I have done something 
wrong in my port.  Any help would be greatly appreciated.

Thanks,
John Lu


Reply via email to