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

Compiler fails to optimize multiple lines of the form dst &= ~src by using BIC instructions

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Implemented
    • Icon: Medium Medium
    • Code Generation Tools
    • CODEGEN-7433
    • Hide
      MSP430_20.2.0.LTS
      ARM_18.12.0.LTS
      MSP430_20.8.0.STS
      MSP430_18.12.0.LTS
      ARM_20.2.0.LTS
      Show
      MSP430_20.2.0.LTS ARM_18.12.0.LTS MSP430_20.8.0.STS MSP430_18.12.0.LTS ARM_20.2.0.LTS
    • Hide
      MSP430_20.2.2.LTS
      ARM_20.2.2.LTS
      MSP430_20.8.0.STS
      MSP430_21.2.0.BETA1*
      Show
      MSP430_20.2.2.LTS ARM_20.2.2.LTS MSP430_20.8.0.STS MSP430_21.2.0.BETA1*
    • default
    • Nothing easy. Either compile without optimisation by using -Ooff, or rearrange the code so the problem does not occur.

      When a program has two or more adjacent, or nearly-adjacent, operations that look like

          dst0 &= ~src;
          dst1 &= ~src;
      

      and optimisation is used, the compiler may not produce BIC instructions for them, instead using a two-instruction sequence like XOR-AND or EOR-AND. The code still behaves correctly, but it's a little slower and a little larger.

      The problem is that the optimiser represents ~X internally as (X^~0), and if it moves sub-expressions around, later stages may not recognise the operation pattern that is best implemented by BIC.

      The problem is more likely to occur with char variables than with int, but there isn't much way to control it other than restructuring the code. The performance effect is small; if it's happening in a critical path, it may be worth doing the work, but otherwise probably not.

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

              Created:
              Updated:
              Resolved: