error: insn does not satisfy its constraints

Bug #1530165 reported by Mark Müller on 2015-12-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Undecided
Unassigned

Bug Description

I have a CPP file which fails to compile with any optimization other than -O0. The output is
" error: insn does not satisfy its constraints:"
and
"internal compiler error: in reload_cse_simplify_operands, at postreload.c:411".

I had filed this as a question, but received no feedback, so I decided to file this bug report.

--------------------------------------------------------------
The output of `arm-none-eabi-g++ -v` is :
Using built-in specs.
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-arm-none-eabi-4_9-2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/lto-wrapper
Target: arm-none-eabi
Configured with: /home/build/work/GCC-4-9-build/src/gcc/configure --target=arm-none-eabi --prefix=/home/build/work/GCC-4-9-build/install-native --libexecdir=/home/build/work/GCC-4-9-build/install-native/lib --infodir=/home/build/work/GCC-4-9-build/install-native/share/doc/gcc-arm-none-eabi/info --mandir=/home/build/work/GCC-4-9-build/install-native/share/doc/gcc-arm-none-eabi/man --htmldir=/home/build/work/GCC-4-9-build/install-native/share/doc/gcc-arm-none-eabi/html --pdfdir=/home/build/work/GCC-4-9-build/install-native/share/doc/gcc-arm-none-eabi/pdf --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-python-dir=share/gcc-arm-none-eabi --with-sysroot=/home/build/work/GCC-4-9-build/install-native/arm-none-eabi --build=i686-linux-gnu --host=i686-linux-gnu --with-gmp=/home/build/work/GCC-4-9-build/build-native/host-libs/usr --with-mpfr=/home/build/work/GCC-4-9-build/build-native/host-libs/usr --with-mpc=/home/build/work/GCC-4-9-build/build-native/host-libs/usr --with-isl=/home/build/work/GCC-4-9-build/build-native/host-libs/usr --with-cloog=/home/build/work/GCC-4-9-build/build-native/host-libs/usr --with-libelf=/home/build/work/GCC-4-9-build/build-native/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-multilib-list=armv6-m,armv7-m,armv7e-m,cortex-m7,armv7-r
Thread model: single
gcc version 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 227977] (GNU Tools for ARM Embedded Processors)

--------------------------------------------------------------
The command I'm using to compile is:
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -std=c++0x -DSTM32F405RGTx -DSTM32F4 -DSTM32 -DDEBUG -Dnullptr=0U -DVS_LOGGING_LEVEL=10 -O2 -g3 -Wall -Wextra -fmessage-length=0 -ffunction-sections -c -fno-exceptions -mslow-flash-data -fno-rtti -save-temps f.cpp

--------------------------------------------------------------
The code is below:
#include <cmath>
#include <limits>
#include <algorithm>

enum MatrixLayout {
 ROW_MAJOR,
 COLUMN_MAJOR
};

namespace MathErrors {

enum Error {
 SUCCESS = 0,
 ARGUMENT_ERROR,
};
}

struct rectangular_tag {};
struct squared_tag : public rectangular_tag {};

template<int NROWS, int NCOLS>
struct MatrixTrait {
 typedef rectangular_tag shape_category;
};

template<int N>
struct MatrixTrait<N, N> {
 typedef squared_tag shape_category;
};

class Indexing {

public:
 Indexing(MatrixLayout layout, int lda) :
  _rowFactor(layout == ROW_MAJOR ? lda : 1),
  _colFactor(layout == ROW_MAJOR ? 1 : lda)
 {}

 inline int operator()(int i, int j) {
  return i * _rowFactor + j * _colFactor;
 }

private:

 int _rowFactor;
 int _colFactor;
};

MathErrors::Error Potrf (MatrixLayout matrix_layout, int n,
  const float * __restrict__ A, squared_tag, int lda,
  float * __restrict__ L, squared_tag, int ldl) {

 Indexing indA(matrix_layout, lda);
 Indexing indL(matrix_layout, ldl);

 bool isspd = true;

 // Main loop.
 for (int j = 0; j < n; j++)
 {
  float d(0.0);
  for (int k = 0; k < j; k++)
  {
   float s(0.0);
   for (int i = 0; i < k; i++)
   {
    s += L[indL(k,i)]*L[indL(j,i)];
   }
   L[indL(j,k)] = s = (A[indA(j,k)] - s)/L[indL(k,k)];
   d = d + s*s;
   isspd = isspd && (A[indA(k,j)] == A[indA(j,k)]);
  }
  d = A[indA(j,j)] - d;
  isspd = isspd && (d > 0.);
  L[indL(j,j)] = std::sqrt(d > 0. ? d : 0.);
  for (int k = j+1; k < n; k++)
  {
   L[indL(j,k)] = 0.;
  }
 }

 if(isspd) {
  return MathErrors::SUCCESS;
 }
 else {
  return MathErrors::ARGUMENT_ERROR;
 }
}

--------------------------------------------------------------
The complete error is:
f.cpp: In function 'MathErrors::Error Potrf(MatrixLayout, int, const float*, squared_tag, int, float*, squared_tag, int)':
f.cpp:91:1: error: insn does not satisfy its constraints:
 }
 ^
(insn 255 258 502 27 (set (reg:SF 31 s15 [326])
        (const_double:SF 0.0 [0x0.0p+0])) f.cpp:81 609 {*thumb2_movsf_vfp}
     (nil))
f.cpp:91:1: internal compiler error: in reload_cse_simplify_operands, at postreload.c:411
Please submit a full bug report,

Hi Mark,

I can reproduce this error with 4.9-2015q3 release but not the 5-2015q4 release.

Changed in gcc-arm-embedded:
status: New → Confirmed
Mark Müller (s-mark-t) wrote :

Hi Thomas

Thank you for the info. Indeed, using 5-2015q4 does fix this error, but produces something similar elsewhere in our code. I've created another bug report for that, #1530664.

Are there any work-arounds for this? The problems occur in a large code base, and without optimizations the code is simply too slow for our microcontroller. I've been able to make things work using 4.9, but it involves hand-tuning some functions (i.e. replacing for-loops with repeated code), and is very fragile (since small, seemingly unrelated changes will bring back the error).

Cheers
Mark

Changed in gcc-arm-embedded:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers