Rate This Document
Findability
Accuracy
Completeness
Readability

-mcmlt-arith

Description

cmlt instructions are generated to reduce the number of instructions for the four basic arithmetic operations.

Usage

Use the -mcmlt-arith option to enable optimization.

Note: This optimization requires the -O3 or higher optimization level.

Result

The test case is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;

void foo( uint32_t *a, uint32_t *b)
{
    for (unsigned i = 0; i < 4; i++)
    {
        uint32_t s = ((a[i]>>((8 * sizeof(uint16_t))-1))
		    &(((uint32_t)1<<(8 * sizeof(uint16_t)))+1))*((uint16_t)-1);
        b[i] = (a[i]+s)^s;
    }
}

Test command:

1
gcc -O3 -mcmlt-arith -S test.c -o test.s
Figure 1 Option disabled
Figure 2 Option enabled

After this option is enabled, the generated assembly code uses the cmlt instruction to simplify a group of calculation instructions, reducing the number of instructions.