Message ID | mvm4mzk0ygc.fsf@hawking.suse.de |
---|---|
State | New |
Headers | show |
On 06/17/14 01:47, Andreas Schwab wrote: > Postreload may transform (set (REGX) (CONST_INT A)) ... (set (REGX) > (CONST_INT B)) to (set (REGX) (CONST_INT A)) ... (set (STRICT_LOW_PART > (REGX)) (CONST_INT B)), but it should do that only if the latter is > cheaper. On m68k, a full word load of a small constant with moveq is > cheaper than doing a byte load with move.b. > > Tested on m68k-suse-linux and x86_64-suse-linux. In both cases the size > of cc1* becomes smaller with this change. > > Andreas. > > PR rtl-optimization/54555 > * postreload.c (move2add_use_add2_insn): Only substitute > STRICT_LOW_PART if it is cheaper. Sadly, Kazu didn't add a testcase for the H8/300 cases which inspired his change, so we don't know if your patch hurts the H8/300 port or not. Let's do better this time ;-) Add a testcase for the m68k port which verifies we're getting the desired code. I don't care if you test the assembly code or test the RTL dumps, just that we have a test for the case where STRICT_LOW_PART is not a win. With a testcase, this is approved. Thanks, jeff
diff --git a/gcc/postreload.c b/gcc/postreload.c index 9d71649..89f0c84 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -1805,10 +1805,14 @@ move2add_use_add2_insn (rtx reg, rtx sym, rtx off, rtx insn) gen_rtx_STRICT_LOW_PART (VOIDmode, narrow_reg), narrow_src); - changed = validate_change (insn, &PATTERN (insn), - new_set, 0); - if (changed) - break; + get_full_set_rtx_cost (new_set, &newcst); + if (costs_lt_p (&newcst, &oldcst, speed)) + { + changed = validate_change (insn, &PATTERN (insn), + new_set, 0); + if (changed) + break; + } } } }