From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2EF3E3858D39; Wed, 8 Feb 2023 03:15:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EF3E3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675826106; bh=v4IA11fkhmZZEKeXoedqB85gXxJ0pQa08PeytEPA/Ko=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WiS1htAY7hO1U0gVZxtO2KvFzFZqfkb2wbFTfOM3rNYSKQ4ybCtH1LsG3Y1TLxzdG zkiLsu06p/k5jjS9urVcP84Zz7MU3gj+OwEXJ4r78LXArwgBiAuEuKtmA76tLE15XJ HbznlcU3UgWJc6qwIZMY+bjkYXd6fcJHs/crwfM8= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/108707] suboptimal allocation with same memory op for many different instructions. Date: Wed, 08 Feb 2023 03:15:05 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail dot com 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: cf_gcctarget 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108707 Hongtao.liu changed: What |Removed |Added ---------------------------------------------------------------------------- Target| |x86_64-*-* i?86-*-* --- Comment #1 from Hongtao.liu --- It's related to memory_move_cost, in RA 1466 /* If this insn loads a parameter from its stack slot, then it 1467 represents a savings, rather than a cost, if the parameter is 1468 stored in memory. Record this fact. 1469 1470 Similarly if we're loading other constants from memory (constant 1471 pool, TOC references, small data areas, etc) and this is the only 1472 assignment to the destination pseudo. 1473 1474 Don't do this if SET_SRC (set) isn't a general operand, if it is 1475 a memory requiring special instructions to load it, decreasing 1476 mem_cost might result in it being loaded using the specialized 1477 instruction into a register, then stored into stack and loaded 1478 again from the stack. See PR52208. 1479 1480 Don't do this if SET_SRC (set) has side effect. See PR56124. */ 1481 if (set !=3D 0 && REG_P (SET_DEST (set)) && MEM_P (SET_SRC (set)) 1482 && (note =3D find_reg_note (insn, REG_EQUIV, NULL_RTX)) !=3D NULL= _RTX 1483 && ((MEM_P (XEXP (note, 0)) 1484 && !side_effects_p (SET_SRC (set))) 1485 || (CONSTANT_P (XEXP (note, 0)) 1486 && targetm.legitimate_constant_p (GET_MODE (SET_DEST (set= )), 1487 XEXP (note, 0)) 1488 && REG_N_SETS (REGNO (SET_DEST (set))) =3D=3D 1)) 1489 && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set))) 1490 /* LRA does not use equiv with a symbol for PIC code. */ 1491 && (! ira_use_lra_p || ! pic_offset_table_rtx 1492 || ! contains_symbol_ref_p (XEXP (note, 0)))) 1493 { 1494 enum reg_class cl =3D GENERAL_REGS; 1495 rtx reg =3D SET_DEST (set); 1496 int num =3D COST_INDEX (REGNO (reg)); 1497 1498 COSTS (costs, num)->mem_cost 1499 -=3D ira_memory_move_cost[GET_MODE (reg)][cl][1] * frequency; 1500 record_address_regs (GET_MODE (SET_SRC (set)), 1501 MEM_ADDR_SPACE (SET_SRC (set)), 1502 XEXP (SET_SRC (set), 0), 0, MEM, SCRATCH, 1503 frequency * 2); 1504 counted_mem =3D true; we use GENERAL_REGS for E_V16SFmode move cost which should be inaccurate, i think when preferred regclass is unknown, we'd better use NO_REGS. 588 /* Costs for NO_REGS are used in cost calculation on the 589 1st pass when the preferred register classes are not 590 known yet. In this case we take the best scenario. */=