== Summary ==
- benchmarking coremark with VRP based extension elimination
 * extension elimination in some cases affecting other optimizations
 * With this improvements are marginal (details below)

== Plan ==
- study crc  where extension elimination is resulting in bad code
- Find a solution

==Details==
If an assignment gimple statement has RHS expression value that can fit in LHS type, truncation is redundant. Zero/sign extensions are redundant in this case and rtl statement can be replaced as

from:
 (insn 12 11 0 (set (reg:SI 110 [ D.4128 ])
         (zero_extend:SI (subreg:HI (reg:SI 117) 0))) c5.c:8 -1
      (nil))
to:
 (insn 12 11 0 (set (subreg/s/u:HI (reg:SI 110 [ D.4128 ]) 0)
         (subreg:HI (reg:SI 117) 0)) c5.c:8 -1
      (nil))

With this change, for the following case:

 short unPack( unsigned char c )
 {
     /* Only want lower four bit nibble */
     c = c & (unsigned char)0x0F ;

     if( c > 7 ) {
         /* Negative nibble */
         return( ( short )( c - 16 ) ) ;
     }
     else
     {
         /* positive nibble */
         return( ( short )c ) ;
     }
 }


asm without elimination
unPack:
     @ args = 0, pretend = 0, frame = 0
     @ frame_needed = 0, uses_anonymous_args = 0
     @ link register save eliminated.
     and r0, r0, #15
     cmp r0, #7
     subhi   r0, r0, #16
     uxthhi  r0, r0
     sxth    r0, r0
     bx  lr
     .size

asm with elimination
unPack:
    @ args = 0, pretend = 0, frame = 0
    @ frame_needed = 0, uses_anonymous_args = 0
    @ link register save eliminated.
    and r0, r0, #15
    cmp r0, #7
    subhi   r0, r0, #16
    sxth    r0, r0
    bx  lr


In some cases, changed rtl statement is not eliminated by later passes and is generated as a mov instruction. Worse, it also seems to affect the other optimization passes and resulting in worse code for crc. Not found the cause for it yet.

_______________________________________________
linaro-toolchain mailing list
linaro-toolchain@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-toolchain

Reply via email to