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.

[参考译文] AM263P4-Q1:Cortex-R5F 代码未使用 VMLA.F32 进行编译

Guru**** 2910880 points

Other Parts Discussed in Thread: AM263P4

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1573207/am263p4-q1-cortex-r5f-code-not-compiling-using-vmla-f32

器件型号:AM263P4-Q1
主题:AM263P4 中讨论的其他器件

工具/软件:

给定后、AM263p4 中适用于 Cortex-R5F 的 llvm 4.0.4 编译器 (ti/ccs2031/ccs/tools/compiler/ti-cgt-armllvm_4.0.4.LTS/bin)


给定这个简单的代码:

typedef struct zDomainCoefficients {
    float k[3];
    float j[3];
} zDomainCoefficients;

typedef struct biQuadStates {
    float x_n1;
    float x_n2;
    float y_n1;
    float y_n2;
    zDomainCoefficients coeffs;
} biQuadStates;


typedef struct biQuadDef {
    float input;
    float output;
    biQuadStates state;
} biQuadDef;

void biquad_calc(biQuadDef *const biquad)
{
    biquad->output = biquad->state.coeffs.k[0] * biquad->input +
                     biquad->state.coeffs.k[1] * biquad->state.x_n1 +
                     biquad->state.coeffs.k[2] * biquad->state.x_n2 -
                     biquad->state.coeffs.j[1] * biquad->state.y_n1 -
                     biquad->state.coeffs.j[2] * biquad->state.y_n2;

    biquad->state.x_n2 = biquad->state.x_n1;
    biquad->state.x_n1 = biquad->input;
    biquad->state.y_n2 = biquad->state.y_n1;
    biquad->state.y_n1 = biquad->output;
}

使用以下命令编译:

tiarmclang -c -g -mcpu=cortex-r5 -mfloat-abi=hard -mfpu=vfpv3-d16 -mlittle-endian -mthumb -Ofast -ffast-math biquad_test.c -o biquad_test.o

我希望看到  VMLA.F32 指令、但看到如下内容:

$ tiarmobjdump -S biquad_test.o

biquad_test.o:  file format elf32-littlearm

Disassembly of section .text.biquad_calc:

00000000 <biquad_calc>:
;                      biquad->state.coeffs.k[1] * biquad->state.x_n1 +
       0: ed90 0a02     vldr    s0, [r0, #8]
;     biquad->output = biquad->state.coeffs.k[0] * biquad->input +
       4: ed90 4a06     vldr    s8, [r0, #24]
;                      biquad->state.coeffs.k[1] * biquad->state.x_n1 +
       8: ed90 5a07     vldr    s10, [r0, #28]
;     biquad->output = biquad->state.coeffs.k[0] * biquad->input +
       c: ed90 6a00     vldr    s12, [r0]
;                      biquad->state.coeffs.k[2] * biquad->state.x_n2 -
      10: ed90 1a03     vldr    s2, [r0, #12]
;                      biquad->state.coeffs.j[1] * biquad->state.y_n1 -
      14: ed90 2a04     vldr    s4, [r0, #16]
;                      biquad->state.coeffs.j[2] * biquad->state.y_n2;
      18: ed90 3a05     vldr    s6, [r0, #20]
;                      biquad->state.coeffs.k[1] * biquad->state.x_n1 +
      1c: ee20 5a05     vmul.f32        s10, s0, s10
;                      biquad->state.coeffs.k[2] * biquad->state.x_n2 -
      20: ed90 7a08     vldr    s14, [r0, #32]
;     biquad->output = biquad->state.coeffs.k[0] * biquad->input +
      24: ee26 4a04     vmul.f32        s8, s12, s8
;                      biquad->state.coeffs.j[1] * biquad->state.y_n1 -
      28: edd0 0a0a     vldr    s1, [r0, #40]
;                      biquad->state.coeffs.j[2] * biquad->state.y_n2;
      2c: edd0 1a0b     vldr    s3, [r0, #44]
;     biquad->output = biquad->state.coeffs.k[0] * biquad->input +
      30: ee35 4a04     vadd.f32        s8, s10, s8
;     biquad->state.x_n1 = biquad->input;
      34: ed80 6a02     vstr    s12, [r0, #8]
;                      biquad->state.coeffs.k[2] * biquad->state.x_n2 -
      38: ee21 1a07     vmul.f32        s2, s2, s14
;     biquad->state.x_n2 = biquad->state.x_n1;
      3c: ed80 0a03     vstr    s0, [r0, #12]
      40: ee22 7a20     vmul.f32        s14, s4, s1
;     biquad->state.y_n2 = biquad->state.y_n1;
      44: ed80 2a05     vstr    s4, [r0, #20]
      48: ee23 3a21     vmul.f32        s6, s6, s3
;                      biquad->state.coeffs.k[1] * biquad->state.x_n1 +
      4c: ee34 1a01     vadd.f32        s2, s8, s2
      50: ee33 3a07     vadd.f32        s6, s6, s14
;                      biquad->state.coeffs.j[1] * biquad->state.y_n1 -
      54: ee31 1a43     vsub.f32        s2, s2, s6
;     biquad->output = biquad->state.coeffs.k[0] * biquad->input +
      58: ed80 1a01     vstr    s2, [r0, #4]
;     biquad->state.y_n1 = biquad->output;
      5c: ed80 1a04     vstr    s2, [r0, #16]
; }
      60: 4770          bx      lr

对为什么不使用 VMLA.F32 指令有什么想法? 这是 24 条关于二阶滤波器的指令、这是普遍接受的性能吗?

谢谢、

Paul

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好:

    我已提请编译器专家注意此主题。 他们应该很快作出反应。

    谢谢

    Ki

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您提请我们注意这一点、并提供了一个简明的测试用例。  我能够重现同样的行为。  我提交了问题 EXT_EP-12949 进行调查。  欢迎点击这个链接。

    谢谢。此致、

    -乔治