------- Comment #6 from rakdver at atrey dot karlin dot mff dot cuni dot cz  
2007-04-20 16:09 -------
Subject: Re:  Missed invariant out of the loop with conditionals and shifts

> void quantum_cnot(int control, int target, unsigned long *state, int size)
> {
>   int i;
> 
>   for(i=0; i<size; i++)
>     {
>       if (state[i] & ((unsigned long) 1 << control))
>         state[i] ^= ((unsigned long) 1 << target);
>     }
> }
> 
> (and more similar loops in libquantum).  It would be nice if rtl 
> loop-invariant
> motion could detect this form:
> 
> (insn 23 22 24 4 (parallel [
>             (set (reg:DI 67)
>                 (lshiftrt:DI (reg:DI 62 [ D.1992 ])
>                     (subreg:QI (reg/v:SI 63 [ control ]) 0)))
>             (clobber (reg:CC 17 flags))
>         ]) 470 {*lshrdi3_1_rex64} (nil)
>     (nil))
> 
> (insn 24 23 25 4 (parallel [
>             (set (reg:SI 68)
>                 (and:SI (subreg:SI (reg:DI 67) 0)
>                     (const_int 1 [0x1])))
>             (clobber (reg:CC 17 flags))
>         ]) 301 {*andsi_1} (nil)
>     (nil))
> 
> and move the invariant (1 << control).

how exactly do you imagine this transformation should work?  The insns
you show essentially are

tmp = x >> control;
z = tmp & 1;

I do not see how to transform just this pattern profitably (without also
seeing that z is only used in condition).

I could hack something in, however handling just this single pattern
specially seems a bit weird to me.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29789

Reply via email to