This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Non-Alignment Issue



Hi all,

How do i tell the compiler to use LDNW instruction rather than LDW for loading??

Even using _nassert(((int)ptr & 0x03)!=0) does not solve this problem

_mem4 instrinsics can be used. But that has to be done at all the place where non-alignment
loading is required.

As the compiler uses LDW always...it results in sever non-alignment issues.
is there any simpler solutions to this other than using instrinsics.

Simulator : c64x+ cycle accurate simualtor.
CCS : 3.3

Regards,
Sandeep

  • Hi Sandeep,

    If you want to perform an unaligned load you should use the _mem4 intrinsic.

    What is causing your integer data to be unaligned?

    Regards,
    Harry

  • Hi Sandeep,

    Usually the compiler acts very conservative, as it does not assume anything implicit.

    So unless we specify that a ptr is aligned by _nasert(), compiler does not use any of the Aligned loads or stores.

    Your observation is against the well-known compiler behavior.

    When you say "severe" non-alignment issues? what is it? is it causing functionality failure?

    Are you always loading 32-bit quantities with the ptr?

    If possible, Can you share the snippet of the code? 

    Regards,

    Venu

  • Instead of _nassert(), can you try the pragma of DATA_ALIGN.

    Eg: 

    #pragma DATA_ALIGN(x, 4)