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.

CGT bug with SPLOOPW on C674x?

I've been porting some code from the C672x to the C674x, and I ran into something that looks like a compiler bug.  Specifically, a speculative ADDSP in a SPLOOPW had a write conflict with a single-cycle operation using the same unit after the end of the loop. 

Here's the original C code (it's populating some vectors for a unit test):

 

f = 1.0f;

g = -1.0f;


for (i = 0; i < TEST_VECT_LENGTH; i++)

{

ctest_src_1[i].re = f * g;

ctest_src_1[i].im = -2.0f * f * g;

f += 1.0f;

g *= -1.0f;

}


f = 1.0f;

g = -1.0f;


for (i = 0; i < TEST_VECT_LENGTH; i++)

{

ctest_ref[i].re = -f * g;

ctest_ref[i].im = 2.0f * f * g;

f += 1.0f;

g *= -1.0f;

}

There are a bunch of loops like this in the code, but in this case the second loop failed to run at all, and the ctest_ref array did not get its new values.
Here's the resulting code that was generated.  I've highlighted what I think are the offending lines.  The first highlighted line (inside the loop) is speculatively executed during the last iteration of the loop.  Its result is written to A6 from the L1 unit in the same cycle as the second highlighted line executes after the loop.  The second line tries to initialize A0 to 1, also using the L1 unit, which fails to happen.  Because the condition register still contains 0 from the previous loop, the second loop never runs.

$C$L65:    ; PIPED LOOP PROLOG

.dwpsn file "../../src/testmdspcvect.c",line 632,column 0,is_stmt

   [ A0]   SPLOOPW 8       ;16               ; (P) 

;** --------------------------------------------------------------------------*

$C$L66:    ; PIPED LOOP KERNEL

$C$DW$L$_test_single_in$146$B:

.dwpsn file "../../src/testmdspcvect.c",line 633,column 0,is_stmt

           NOP             1


           SPMASK          L1,S1,D1

||         MV      .L1     A10,A7

||         MV      .S1     A10,A6            ; |629| 

||         MV      .D1X    B12,A8


           SPMASK          L2,S2

||         MVKL    .S2     _ctest_src_1,B7

||         ZERO    .L2     B8

||         MPYSP   .M1     A8,A6,A6          ; |635| (P) <0,2> 

||         ADDSP   .L1     A7,A6,A9          ; |635| (P) <0,2>  ^ 


           SPMASK          S2

||         MVKH    .S2     0xbf800000,B8


           SPMASK          L2,S2

||         ZERO    .L2     B9                ; |637| 

||         MVKH    .S2     _ctest_src_1,B7

||         MPYSP   .M2X    B8,A6,B4          ; |632| (P) <0,4> 


           SET     .S2     B9,31,31,B5       ; |637| (P) <0,5> 


           SPMASK          S1,D1

||         ZERO    .S1     A5                ; |637| 

||         ADD     .D1X    4,B7,A3

||         XOR     .L2     B8,B5,B16         ; |637| (P) <0,6> 

||         ADDSP   .L1     A7,A9,A6          ; |636| (P) <0,6>  ^ 

||         MPYSP   .M1     A8,A9,A16         ; |635| (P) <0,6> 


           SPMASK          S1,L2

||         MVK     .S1     64,A4             ; |632| 

||         ADD     .L2     8,B7,B6

||         ADD     .L1     2,A5,A5           ; |632| (P) <0,7> 

||         MPYSP   .M1X    B8,A6,A17         ; |635| (P) <0,7> 

||         MPYSP   .M2X    B16,A9,B4         ; |635| (P) <0,7> 


           STW     .D2T2   B4,*B7++(16)      ; |632| <0,8> 

||         CMPLT   .L1     A5,A4,A9          ; |632| <0,8> 


           NOP             1

           SET     .S2     B9,31,31,B5       ; |637| <0,10> 


           MV      .L1     A9,A0             ; |632| <0,11> 

||         XOR     .L2     B16,B5,B8         ; |637| <0,11> 

||         STW     .D1T1   A17,*A3++(16)     ; |635| <0,11> 

||         MPYSP   .M2X    B16,A16,B5        ; |635| <0,11> 


           NOP             2

           NOP             1


           SPKERNEL 0,0

||         STDW    .D2T2   B5:B4,*B6++(16)   ; |635| <0,15> 


.dwpsn file "../../src/testmdspcvect.c",line 638,column 0,is_stmt

           NOP             1                 ; SDSCM00012367 HW bug workaround

$C$DW$L$_test_single_in$146$E:

;** --------------------------------------------------------------------------*

$C$L67:    ; PIPED LOOP EPILOG

;** --------------------------------------------------------------------------*

           MVK     .L1     0x1,A0            ; init sploopw predicate

;*----------------------------------------------------------------------------*


;*----------------------------------------------------------------------------*

$C$L68:    ; PIPED LOOP PROLOG

.dwpsn file "../../src/testmdspcvect.c",line 643,column 0,is_stmt

   [ A0]   SPLOOPW 8       ;16               ; (P) 

 

I'm sorry if this is a false alarm, or if this bug has already been reported.  If my understanding of the problem is incorrect, please let me know.

Thanks,

Michael