`insn does not satisfy its constraints` when compiling a simple program.

2020-04-18 Thread Joe via Gcc

Hello,

I am working on writing a backend for a new architecture but I have 
encountered a problem.


When I try to compile the following simple program with -O0 (note: this 
problem does not occur when optimizations are enabled):


int main()
{
int a = 10;
a++;
}

I get this error:

test.c: In function ‘main’:
test.c:5:1: error: insn does not satisfy its constraints:
5 | }
  | ^
(insn 8 7 9 (set (reg:SI 12)
(plus:SI (reg:SI 13)
(const_int 1 [0x1]))) "test.c":4:6 1 {addsi3}
 (nil))
during RTL pass: final
test.c:5:1: internal compiler error: in final_scan_insn_1, at final.c:3012
0x65f4b2 _fatal_insn(char const*, rtx_def const*, char const*, int, char 
const*)

../../gcc/gcc/rtl-error.c:108
0x65f4d8 _fatal_insn_not_found(rtx_def const*, char const*, int, char 
const*)

../../gcc/gcc/rtl-error.c:118
0x5e2fc8 final_scan_insn_1
../../gcc/gcc/final.c:3012
0xa23e0b final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
../../gcc/gcc/final.c:3152
0xa24099 final_1
../../gcc/gcc/final.c:2020
0xa249f2 rest_of_handle_final
../../gcc/gcc/final.c:4658
0xa249f2 execute
../../gcc/gcc/final.c:4736

Based on what the error message says the problem seems to be with the 
constraints in the definition of addsi3. Here is the definition of addsi3:


(define_insn "addsi3"
  [(set (match_operand:SI 0 "register_operand" "=r,r")
(plus:SI (match_operand:SI 1 "register_operand" "r,r")
 (match_operand:SI 2 "reg_or_imm_operand" "r,I")))]
  "1"
  "@
   add %0 %1 %2
   addi %0 %1 %2")

Here is the definition for the 'I' constraint:

(define_constraint "I"
  "A 30-bit immediate."
  (and (match_code "const_int")
   (match_test "ival >= -536870912 && ival <= 536870911")))

The program compiles successfully if the constraints in the definition 
of addsi3 are removed.


If more specific information is needed please let me know and I will try 
provide it.


Sorry if this is not the best place to ask this question, I was not sure 
where to ask it. I had previously asked it on StackOverflow but with no 
luck.


Thanks in advance.

Joe Legg


gcc-9-20200418 is now available

2020-04-18 Thread GCC Administrator via Gcc
Snapshot gcc-9-20200418 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/9-20200418/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 9 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch releases/gcc-9 
revision b29ea6948c8e936b07ff8befad7befee6dbfe1a5

You'll find:

 gcc-9-20200418.tar.xzComplete GCC

  SHA256=0ab209ee0f48b12a0395444d7dfba224e976c065bf2ed821e3b7933f38e475db
  SHA1=096defe6a4e56e9d384a3cb93e1198798b791892

Diffs from 9-20200411 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-9
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.