------- Comment #2 from hutchinsonandy at gcc dot gnu dot org  2008-07-22 02:37 
-------
4.2.2 has same issue.

Can someone benchmark -fno-if-conversion for AVR?

Transforms are made independent of target. BRANCH_COST is already 0 for avr.

Here is a related example. This time result  is a power of two so it needs a
more complicated shift.

int z;

int foo2(void)
{
  if ( ++z >= 0)
  return 16;
  else
  return 0;

}

produces:
  24                    .LM2:
  25                    /*DEBUG: 0x0            0       12 */
  26 0000 8091 0000             lds r24,z
  27 0004 9091 0000             lds r25,(z)+1
  28                    /*DEBUG: 0x4            4       8 */
  29 0008 0196                  adiw r24,1
  30                    /*DEBUG: 0x5            1       12 */
  31 000a 9093 0000             sts (z)+1,r25
  32 000e 8093 0000             sts z,r24
  33                    /*DEBUG: 0x9            4       16 */
  34 0012 292F                  mov r18,r25
  35 0014 220F                  lsl r18
  36 0016 330B                  sbc r19,r19
  37 0018 2795                  ror r18
  38                    /*DEBUG: 0xd            4       12 */
  39 001a 2095                  com r18
  40 001c 3095                  com r19
  41                    /*DEBUG: 0xf            2       28 */
  42 001e 2227                  clr r18
  43 0020 330F                  lsl r19
  44 0022 221F                  rol r18
  45 0024 3327                  clr r19
  46                    /*DEBUG: 0x13           4       44 */
  47 0026 2295                  swap r18
  48 0028 3295                  swap r19
  49 002a 307F                  andi r19,0xf0
  50 002c 3227                  eor r19,r18
  51 002e 207F                  andi r18,0xf0
  52 0030 3227                  eor r19,r18
  53                    .LM3:
  54                    /*DEBUG: 0x19           6       4 */
  55 0032 C901                  movw r24,r18
  56                    /* epilogue start */
  57                    /*DEBUG: 0x1a           1       4 */
  58 0034 0895                  ret

If I played around with mode of operands I'm sure I could do worse.


-- 


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

Reply via email to