jkmcnk / sx-gcc

The GNU Compiler Collection port to NEC SX CPU architecture.
GNU General Public License v2.0
0 stars 2 forks source link

suboptimal register + immediate operations #57

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
when gcc emits code for arithmetic operations involving a var (register)
and a constant (immediate), it emits two instructions:
1. loading constant to a register
2. register <- register op register

the most notable case of such code is
  n--
which is compiled to
  or    $s37,1,(0)1      # $s37 <- 1
  cpx   $s35,$s40,$s37   # $s35 <- $s40 - $s37

for constants like 1, easily created by a mask, gcc could emit just a
single instruction
1. register <- register op immediate

Original issue reported on code.google.com by jmoc...@gmail.com on 26 Nov 2008 at 3:39

GoogleCodeExporter commented 8 years ago
this is probably a thing that combiner/optimizer should do, anyway, and not due 
to
our md. need to check behaviour with -O0 and -O>0.

Original comment by jmoc...@gmail.com on 15 Jan 2009 at 12:28