[EXT_EP-11231] Compiler emits the wrong constant when the input to __delay_cycles exceeds INT32_MAX Created: 07/Jul/23  Updated: 10/Jul/23

Status: New
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Low
Reporter: TI User Assignee: TI User
Resolution: Unresolved Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: Code Generation Tools
Internal ID: CODEGEN-11257
Forum URL: https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/81/t/1245850
Found In Release: PRU_2.3.3
Affected Platform/Device: default

 Description   

The problem only occurs when building on Linux.

The attached file.c contains these lines ...

const uint32_t MAX_CYCLES_WITHOUT_ERROR = INT32_MAX;
void main(void)
{
  __delay_cycles(MAX_CYCLES_WITHOUT_ERROR);
  __delay_cycles(MAX_CYCLES_WITHOUT_ERROR+22);
}

Build it ...

$ clpru -s file.c
"file.asm", WARNING! at line 76: [W0001] Constant value out of range, will be
                                         truncated to 32 bits
                LDI32    r0, 9223372035781033993

No Assembly Errors, 1 Assembly Warning

This line is associated with the second call to __delay_cycles. When built on Windows, the compiler emits this instead ...

        LDI32    r0, 1073741833

Generated at Wed Apr 23 23:17:15 CDT 2025 using Jira 9.12.17#9120017-sha1:aba4002bcd633f188b6a4bb5dd8a0e1f20b79ee4.