From 46786144dd77505a5e06c8ac9fd353e84eb38d89 Mon Sep 17 00:00:00 2001 From: Segher Boessenkool Date: Wed, 17 Apr 2019 20:49:50 +0200 Subject: [PATCH] auto-inc-dec: Set alignment properly When auto-inc-dec creates a new mem to compute the cost of doing some transform, it forgets to copy over the alignment of the original mem. This gives wrong costs, for example, for rs6000 a floating point load or store is hugely expensive if unaligned. This patch fixes it. * auto-inc-dec.c (attempt_change): Set the alignment of the temporary memory to that of the original. From-SVN: r270419 --- gcc/ChangeLog | 9 +++++++-- gcc/auto-inc-dec.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d18462109b0..2138006a8b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,9 @@ -2019-04-10 Joao Moreira +2019-04-17 Segher Boessenkool + + * auto-inc-dec.c (attempt_change): Set the alignment of the + temporary memory to that of the original. + +2019-04-17 Joao Moreira * targhooks.c (default_print_patchable_function_entry): Emit __patchable_function_entries section with writable flags to allow @@ -6,7 +11,7 @@ 2019-04-17 Jonny Grant - * collect2.c (main): Change gcc.gnu.org URL to HTTPS. + * collect2.c (main): Change gcc.gnu.org URL to HTTPS. 2019-04-17 Jakub Jelinek diff --git a/gcc/auto-inc-dec.c b/gcc/auto-inc-dec.c index 43400ccbec7..bdb6efab520 100644 --- a/gcc/auto-inc-dec.c +++ b/gcc/auto-inc-dec.c @@ -471,6 +471,7 @@ attempt_change (rtx new_addr, rtx inc_reg) int regno; rtx mem = *mem_insn.mem_loc; machine_mode mode = GET_MODE (mem); + int align = MEM_ALIGN (mem); rtx new_mem; int old_cost = 0; int new_cost = 0; @@ -478,6 +479,7 @@ attempt_change (rtx new_addr, rtx inc_reg) PUT_MODE (mem_tmp, mode); XEXP (mem_tmp, 0) = new_addr; + set_mem_align (mem_tmp, align); old_cost = (set_src_cost (mem, mode, speed) + set_rtx_cost (PATTERN (inc_insn.insn), speed)); -- 2.30.2