Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-9617

Compiler fails to optimize expression dst &= ~src to BIC instruction

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Implemented
    • Icon: Low Low

      The attached file contains this line ...

      dst &= ~src;
      

      The variables dst and src are of type unsigned char. Build it with optimization ...

      cl430 -o -s try1.c
      

      The resulting assembly for that line is ...

      ;** 5   -----------------------    dst &= src^0xff;
              .dwpsn  file "try1.c",line 5,column 5,is_stmt,isa 0
              MOV.W     #255,r15              ; [] |5|
              XOR.B     &src+0,r15            ; [] |5|
              AND.B     r15,&dst+0            ; [] |5|
      

      However, build it with optimization disabled ...

      cl430 -ooff -s try1.c
      

      ... and the generated code uses the BIC instruction ...

      ;----------------------------------------------------------------------
      ;   5 | dst &= ~src;
      ;----------------------------------------------------------------------
              BIC.B     &src+0,&dst+0         ; [] |5|
      

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: