From f482b86d5d56c9a3b3ec8fd03f24a242c9609048 Mon Sep 17 00:00:00 2001 From: uwe Date: Mon, 24 Jul 2006 23:36:03 +0000 Subject: [PATCH] gcc4 generated extremely unoptimal code for shifts of 64-bit ints on SuperH. Pull over a fix from gcc 4.1 branch. ok mrg@ Author: sayle Date: Fri Jul 21 13:22:31 2006 New Revision: 115644 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115644 Log: PR middle-end/28283 * expmed.c (expand_shift): Additionally check that the shift_cost is not MAX_COST and that INTVAL(op1) is less than MAX_BITS_PER_WORD before implementing a LSHIFT_EXPR as a sequence of additions. * config/sh/sh.c (shift_costs): Return MAX_COST to inform the middle-end that DImode shifts need to be synthesized by expand. Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/config/sh/sh.c branches/gcc-4_1-branch/gcc/expmed.c --- gnu/dist/gcc4/gcc/ChangeLog | 9 +++++++++ gnu/dist/gcc4/gcc/config/sh/sh.c | 2 +- gnu/dist/gcc4/gcc/expmed.c | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/gnu/dist/gcc4/gcc/ChangeLog b/gnu/dist/gcc4/gcc/ChangeLog index 4dcb250c3725..a4a1ba3ad41b 100644 --- a/gnu/dist/gcc4/gcc/ChangeLog +++ b/gnu/dist/gcc4/gcc/ChangeLog @@ -1,3 +1,12 @@ +2006-07-21 Roger Sayle + + PR middle-end/28283 + * expmed.c (expand_shift): Additionally check that the shift_cost + is not MAX_COST and that INTVAL(op1) is less than MAX_BITS_PER_WORD + before implementing a LSHIFT_EXPR as a sequence of additions. + * config/sh/sh.c (shift_costs): Return MAX_COST to inform the + middle-end that DImode shifts need to be synthesized by expand. + 2006-06-25 Eric Botcazou PR middle-end/28151 diff --git a/gnu/dist/gcc4/gcc/config/sh/sh.c b/gnu/dist/gcc4/gcc/config/sh/sh.c index 3a8dbbe7521f..216bbab447db 100644 --- a/gnu/dist/gcc4/gcc/config/sh/sh.c +++ b/gnu/dist/gcc4/gcc/config/sh/sh.c @@ -1910,7 +1910,7 @@ shiftcosts (rtx x) return 2; /* Everything else is invalid, because there is no pattern for it. */ - return 10000; + return MAX_COST; } /* If shift by a non constant, then this will be expensive. */ if (GET_CODE (XEXP (x, 1)) != CONST_INT) diff --git a/gnu/dist/gcc4/gcc/expmed.c b/gnu/dist/gcc4/gcc/expmed.c index 0ada3bbf51aa..eed3a48c589b 100644 --- a/gnu/dist/gcc4/gcc/expmed.c +++ b/gnu/dist/gcc4/gcc/expmed.c @@ -2208,7 +2208,9 @@ expand_shift (enum tree_code code, enum machine_mode mode, rtx shifted, && GET_CODE (op1) == CONST_INT && INTVAL (op1) > 0 && INTVAL (op1) < GET_MODE_BITSIZE (mode) - && shift_cost[mode][INTVAL (op1)] > INTVAL (op1) * add_cost[mode]) + && INTVAL (op1) < MAX_BITS_PER_WORD + && shift_cost[mode][INTVAL (op1)] > INTVAL (op1) * add_cost[mode] + && shift_cost[mode][INTVAL (op1)] != MAX_COST) { int i; for (i = 0; i < INTVAL (op1); i++)