From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2DBED383B807; Mon, 28 Jun 2021 03:27:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DBED383B807 From: "linkw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/100328] IRA doesn't model matching constraint well Date: Mon, 28 Jun 2021 03:27:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: linkw at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: linkw at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jun 2021 03:27:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100328 --- Comment #5 from Kewen Lin --- Created attachment 51065 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D51065&action=3Dedit ira: Consider matching constraint heavily with some parameter v3 The mentioned only one aarch64-linux-gnu "PASS->FAIL" regression failure exposes one issue: how to set up the costs when either of matching constrai= nt two sides is hardware register (hw reg for short later) meanwhile there are several operands can have the matching constraint. Without this patch, the constraint copy is simply taken as a real move insn, so when there is one hw reg, it set the preference and conflict cost as big value, it's good since = we used to create constraint copy when there is only one operand respecting matching constraint. With this patch, we allow there are several input oper= ands respecting the same matching constraint (but in different alternatives), so even there is one hw reg, we can't set the preference/conflict cost with hi= gh value. CASE 1: hw_reg0 =3D reg1, reg2, reg3 ... (op1/2/3 has the matching constraint on = op0) We can make reg1/reg2/reg3 be preferred to be assigned by hw_reg0 over the other hw_regs. But reg1/reg2/reg3 conflicts with any of the others, we can't make reg1's conflict objects be disparaged on hw_reg0 since it can affect hw_reg0 to be assigned onto reg2/reg3 and also their allocno copies. So mak= e it simply as shuffle copy. CASE 2: reg0 =3D hw_reg1, reg2, reg3 ... (op1/2/3 has the matching constraint on = op0) hw_reg1 is just one option to be assigned to reg0, shouldn't give it much c= ost otherwise it can disparage reg0's copies with reg2/reg3. Now the patch simp= le takes it as shuffle copy, so it slightly prefer hw_reg1, but still have the flexibility to go with some hw_reg in reg2/reg3. Note that we can early cat= ch this in function ira_get_dup_out_num, but I think it might be more clear to leave the handling in process_regs_for_copy near the CASE1 handling and eas= ier to tweak it in case we have the need.=