• AVR Freaks

Hot!Compile error 'unrecognizable insn'

Author
johndsd
Senior Member
  • Total Posts : 124
  • Reward points : 0
  • Joined: 2014/02/13 04:29:22
  • Location: 0
  • Status: offline
2019/04/17 09:16:24 (permalink)
0

Compile error 'unrecognizable insn'

I am getting a compile error 'unrecognizable insn' for a function called 'intrp3d_u8u8s16n10l_ne' which is auto generated by Simulink embedded coder.
 
The strange thing is that it compiles fine for a different Simulink model which uses the exact same function and calls to those functions !  ???
 
All I did was strip parts out from the original Simulink model but both models use the same function, yet the original model compiles but stripped down model has this compile error.
 
I have compared the auto generated code of the functions (as well as the the calls to those functions) between the original model and the stripped down model - they are exactly the same.
 
As they are exactly the same (which you would expect), why will one compile but the other wont ?
 
The XC16 compiler is v1.24.
 
The compile error can be seen in the attached picture (this forum wouldn't let me post as text so I had to screenshot it).
 
This is the auto generated function from the stripped down model (which is exactly the same as the function from the original model)...

 
uint8_T intrp3d_u8u8s16n10l_ne(const uint8_T bpIndex[], const int16_T frac[],
 
  const uint8_T table[], const uint32_T stride[])
{
  uint8_T y;
  uint8_T yL_2d;
  uint32_T offset_2d;
  uint8_T yL_1d;
  uint8_T yR_1d;
  uint32_T offset_0d;
  int32_T tmp;

  /* Interpolation 3-D
     Interpolation method: 'Linear'
     Use last breakpoint for index at or above upper limit: 'off'
     Rounding mode: 'nearest'
     Overflow mode: 'wrapping'
   */
  offset_2d = (bpIndex[2UL] * stride[2UL] + bpIndex[1UL] * stride[1UL]) +
    bpIndex[0UL];
  if (table[offset_2d + 1UL] >= table[offset_2d]) {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_2d + 1UL] - table[offset_2d])
      * frac[0UL];
    yL_1d = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                      table[offset_2d]);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_2d] - table[offset_2d + 1UL])
      * frac[0UL];
    yL_1d = (uint8_T)((uint16_T)table[offset_2d] - (uint8_T)(((tmp & 512L) != 0L)
      + (tmp >> 10)));
  }

  offset_0d = offset_2d + stride[1UL];
  if (table[offset_0d + 1UL] >= table[offset_0d]) {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_0d + 1UL] - table[offset_0d])
      * frac[0UL];
    yR_1d = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                      table[offset_0d]);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_0d] - table[offset_0d + 1UL])
      * frac[0UL];
    yR_1d = (uint8_T)((uint16_T)table[offset_0d] - (uint8_T)(((tmp & 512L) != 0L)
      + (tmp >> 10)));
  }

  if (yR_1d >= yL_1d) {
    tmp = (int32_T)(uint8_T)((uint16_T)yR_1d - yL_1d) * frac[1UL];
    yL_2d = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                      yL_1d);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)yL_1d - yR_1d) * frac[1UL];
    yL_2d = (uint8_T)((uint16_T)yL_1d - (uint8_T)(((tmp & 512L) != 0L) + (tmp >>
      10)));
  }

  offset_2d += stride[2UL];
  if (table[offset_2d + 1UL] >= table[offset_2d]) {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_2d + 1UL] - table[offset_2d])
      * frac[0UL];
    yL_1d = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                      table[offset_2d]);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_2d] - table[offset_2d + 1UL])
      * frac[0UL];
    yL_1d = (uint8_T)((uint16_T)table[offset_2d] - (uint8_T)(((tmp & 512L) != 0L)
      + (tmp >> 10)));
  }

  offset_0d = offset_2d + stride[1UL];
  if (table[offset_0d + 1UL] >= table[offset_0d]) {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_0d + 1UL] - table[offset_0d])
      * frac[0UL];
    yR_1d = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                      table[offset_0d]);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)table[offset_0d] - table[offset_0d + 1UL])
      * frac[0UL];
    yR_1d = (uint8_T)((uint16_T)table[offset_0d] - (uint8_T)(((tmp & 512L) != 0L)
      + (tmp >> 10)));
  }

  if (yR_1d >= yL_1d) {
    tmp = (int32_T)(uint8_T)((uint16_T)yR_1d - yL_1d) * frac[1UL];
    yL_1d = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                      yL_1d);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)yL_1d - yR_1d) * frac[1UL];
    yL_1d = (uint8_T)((uint16_T)yL_1d - (uint8_T)(((tmp & 512L) != 0L) + (tmp >>
      10)));
  }

  if (yL_1d >= yL_2d) {
    tmp = (int32_T)(uint8_T)((uint16_T)yL_1d - yL_2d) * frac[2UL];
    y = (uint8_T)((uint16_T)(uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)) +
                  yL_2d);
  } else {
    tmp = (int32_T)(uint8_T)((uint16_T)yL_2d - yL_1d) * frac[2UL];
    y = (uint8_T)((uint16_T)yL_2d - (uint8_T)(((tmp & 512L) != 0L) + (tmp >> 10)));
  }

  return y;
}

 
post edited by johndsd - 2019/04/17 09:35:52

Attached Image(s)

#1

11 Replies Related Threads

    andersm
    Super Member
    • Total Posts : 2621
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/17 10:29:48 (permalink)
    +2 (2)
    It's a compiler bug, file a bug report.
    #2
    rodims
    Super Member
    • Total Posts : 1508
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: online
    Re: Compile error 'unrecognizable insn' 2019/04/17 10:42:11 (permalink)
    +1 (1)
    You might try a newer XC16 compiler version.
    #3
    du00000001
    Just Some Member
    • Total Posts : 2889
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/17 11:58:02 (permalink)
    +1 (1)
    All files included are identical as well? (Not just the #include lines but the included files!)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #4
    johndsd
    Senior Member
    • Total Posts : 124
    • Reward points : 0
    • Joined: 2014/02/13 04:29:22
    • Location: 0
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 02:01:57 (permalink)
    0
    rodims
    You might try a newer XC16 compiler version.



    That would be good if I had that option, unfortunately when I upgrade to V1.26 (I dont have a subscription to upgrade any higher) the CCP driver no longer works and I dont know why, it might not even be the CCP driver itself it could be ECAN or something else.  The code compiles wtih V1.26 but CCP doesnt work - the CCP driver is the free one supplied by Vector.  For this reason I have not upgraded from V1.24.
     
    I had an issue when I upgraded from V1.22 to V1.24, the the ECAN driver (based on Microchips example code) compiled with v1.22 but when I upgraded to v1.24 I got the compile error 'error: unrecognizable insn:'. 
     
    The fix was to change the variables used in the functions that used ECAN registers to 'volatile' (see attached image)
     
     
     
     
     
     
     

    Attached Image(s)

    #5
    rodims
    Super Member
    • Total Posts : 1508
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: online
    Re: Compile error 'unrecognizable insn' 2019/04/18 04:50:36 (permalink)
    +1 (1)
    The fix was to change the variables used in the functions that used ECAN registers to 'volatile'

    This means your original POST is resolved ?
     
    That would be good if I had that option, unfortunately when I upgrade to V1.26 (I dont have a subscription to upgrade any higher)

     
    At least for testing and comparing you can install newer versions like current V1.36 in parallel (free license).
    Depending on your requirements the free license may work quite well.
     
     
    #6
    johndsd
    Senior Member
    • Total Posts : 124
    • Reward points : 0
    • Joined: 2014/02/13 04:29:22
    • Location: 0
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 05:27:55 (permalink)
    0

    This means your original POST is resolved ?
     

     
    No, because that was the issue when I upgraded from V1.22 to V1.24 some years ago and the issue was with the ECAN driver.
     
    This is a different issue with V1.24 and the issue is with the generated code for the function 'intrp3d_u8u8s16n10l_ne'.  Coincidentally it does give the same compile error 'unrecognizable insn' but its an entirely different issue.
     

    At least for testing and comparing you can install newer versions like current V1.36 in parallel (free license).
    Depending on your requirements the free license may work quite well.

     
     
    I need optimisation (level 3) for the software to run on the processor, without optimisation the processor does not run the code.
     
    I did try compiling with V1.25 and that fixed the compile error, without testing Im not sure if V1.25 will cause any other problems (like I said, V1.26 caused CCP to stop working).
     
    What doesnt make sense is that for the original generated code which uses the same function it compiles without any errors, its only the stripped down version that has the issue. 
    #7
    du00000001
    Just Some Member
    • Total Posts : 2889
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 05:46:22 (permalink)
    +1 (1)
    an aside:
    When using code provided from Vector (and other similar suppliers): is this source or object code?
    They usually state which compiler version to use, and it might be a bad idea to deviate from this.
    (It's quite weird that your code does compile, but then refuses to execute as expected  sad )

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #8
    johndsd
    Senior Member
    • Total Posts : 124
    • Reward points : 0
    • Joined: 2014/02/13 04:29:22
    • Location: 0
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 08:12:16 (permalink)
    0
    du00000001
    an aside:
    When using code provided from Vector (and other similar suppliers): is this source or object code?
    They usually state which compiler version to use, and it might be a bad idea to deviate from this.
    (It's quite weird that your code does compile, but then refuses to execute as expected  sad )


    This is source code
     
    https://automotivetechis.files.wordpress.com/2012/06/an-imc-1-001_integration_of-the_vector_ccp_driver_with_a_free_can_driver.pdf
    #9
    johndsd
    Senior Member
    • Total Posts : 124
    • Reward points : 0
    • Joined: 2014/02/13 04:29:22
    • Location: 0
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 08:14:44 (permalink)
    0
    The reason why the code doesnt execute with no optimisation is because tasks overrun as there is so much for the processor to do.
    #10
    du00000001
    Just Some Member
    • Total Posts : 2889
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 08:22:43 (permalink)
    +1 (1)
    johndsd
    This is source code
     
    https://automotivetechis.files.wordpress.com/2012/06/an-imc-1-001_integration_of-the_vector_ccp_driver_with_a_free_can_driver.pdf

    A look inside reveals they tested it with COSMIC C.
     
    As you seem to have already found out that some missing volatile qualifier caused some problem(s), this might be the case as well for the current issue.
    A missing volatile might be the cause for malfunctions as it might result in code reading a variable once - then comparing it ever and ever again while not noticing an update. The XC compiler family is quite good in (should I call it "notorious" or "infamous" for) this kind of optimization.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #11
    du00000001
    Just Some Member
    • Total Posts : 2889
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Compile error 'unrecognizable insn' 2019/04/18 08:28:15 (permalink)
    +1 (1)
    johndsd
    The reason why the code doesnt execute with no optimisation is because tasks overrun as there is so much for the processor to do.



    How is the search for the points to interpolate between implemented? Linear or by ever dividing the interval by 2?
    (The latter is way faster.)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #12
    Jump to:
    © 2019 APG vNext Commercial Version 4.5