From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CF7F33858CDA; Thu, 9 May 2024 12:21:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF7F33858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715257272; bh=u6hukVJ4fGUeMxK90kK1Z69gFK47T1dZVaNl6a4jLE0=; h=From:To:Subject:Date:From; b=uElKwy9W0xXgDzKMO176R96mzh1NK0TKHUDdiGvlZ9HTP3vyci/iLmXfix70koaMF KON9Gw2PLBir1wa35pbE4IQpVEuNS3+d7ceJJPFnVy0Wx44ZX5UPZvyFo5NaFcOhlA yhQOIGFISi4wbOqBT2AQZMNW+0t1xJndfkJYoTpI= From: "admin@tho-otto.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/115010] New: m68k: invalid subl instruction generated Date: Thu, 09 May 2024 12:21:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: admin@tho-otto.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115010 Bug ID: 115010 Summary: m68k: invalid subl instruction generated Product: gcc Version: 14.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: admin@tho-otto.de Target Milestone: --- While configuring a cross-compiler for m68k, and then trying to use that cross-compiler to build a native compiler, a wrong subl instruction gets generated: Assembler messages: /tmp/ccpLXgrk.s:16664: Error: operands mismatch -- statement sub.l -402(%fp),-446(%fp)' ignored /tmp/ccpLXgrk.s:16813: Error: operands mismatch -- statement sub.l -274(%fp),-302(%fp)' ignored make[1]: *** [Makefile:1202: tree-data-ref.o] Error 1 That instruction is invalid, because atleast one of the operands must be a = data register. Unfortunately the steps to reproduce are a bit complicated, using a bare m68k-elf target not work, because for the 2nd step you will also need a wor= king c-library. And of course you also need binutils for that target. I should also mention that the same bug already happened in gcc 11.4.0, but strangely not in gcc 13.2.0 or gcc 12.3.0 (but maybe this was just by incident). The problem also disappears when compiling tree-data-ref.c using -Os instea= d of -O2. I'm not that really familiar with the machine description files, but to me (define_insn "subsi3" [(set (match_operand:SI 0 "nonimmediate_operand" "=3Dmd,ma,m,d,a") (minus:SI (match_operand:SI 1 "general_operand" "0,0,0,0,0") (match_operand:SI 2 "general_src_operand" "I,I,dT,mSrT,mSrs")))] "" "@ subq%.l %2, %0 subq%.l %2, %0 sub%.l %2,%0 sub%.l %2,%0 sub%.l %2,%0" [(set_attr "type" "aluq_l,aluq_l,alu_l,alu_l,alu_l") (set_attr "opy" "2") (set_attr "flags_valid" "noov,unchanged,noov,noov,unchanged")]) Looks suspicious. If i'm not wrong, that pattern is used to turn something = like "x =3D x - y" into "x -=3D y". But alternative 3 can match a memory operand= for operand 0, and constraint 'T' for operand 2 is defined as (define_constraint "T" "Used for operands that satisfy 's' when -mpcrel is not in effect." (and (match_code "symbol_ref,label_ref,const") (match_test "!TARGET_PCREL") (match_test "!flag_pic || LEGITIMATE_PIC_OPERAND_P (op)"))) so it can match a symbol_ref. Could that be the cause?=