From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4532 invoked by alias); 24 Mar 2011 12:13:42 -0000 Received: (qmail 4522 invoked by uid 22791); 24 Mar 2011 12:13:39 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Mar 2011 12:13:34 +0000 Received: by wwj40 with SMTP id 40so10483888wwj.8 for ; Thu, 24 Mar 2011 05:13:32 -0700 (PDT) Received: by 10.216.240.3 with SMTP id d3mr661262wer.51.1300968811329; Thu, 24 Mar 2011 05:13:31 -0700 (PDT) Received: from richards-thinkpad (gbibp9ph1--blueice2n1.emea.ibm.com [195.212.29.75]) by mx.google.com with ESMTPS id y12sm3366809wby.59.2011.03.24.05.13.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2011 05:13:30 -0700 (PDT) From: Richard Sandiford To: Andreas Krebbel Mail-Followup-To: Andreas Krebbel ,gcc-patches@gcc.gnu.org, rth@redhat.com, richard.sandiford@linaro.org Cc: gcc-patches@gcc.gnu.org, rth@redhat.com Subject: Re: Cleaning up expand optabs code References: <4D825EF5.1010307@redhat.com> <87wrju28hn.fsf@firetop.home> <4D87A69B.90704@redhat.com> <4D88E10A.8080005@redhat.com> <4D8B32A9.9050309@linux.vnet.ibm.com> Date: Thu, 24 Mar 2011 12:13:00 -0000 In-Reply-To: <4D8B32A9.9050309@linux.vnet.ibm.com> (Andreas Krebbel's message of "Thu, 24 Mar 2011 13:01:45 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg01595.txt.bz2 Andreas Krebbel writes: > On 03/22/2011 06:48 PM, Richard Henderson wrote: > >> Ok. Watch out for other target problems this week. > > This unfortunately broke bootstrap on s390. This is PR 48263. Since it seems to be affecting several targets, and since my bootstrap seems to be taking a looong time, I'll post the patch here before testing has finished. > Just copying the pre-patch behaviour fixes the problem for me: I think we need to undo more of the patch, and leave the conversion outside of the new interface. Sorry for the breakage. Richard gcc/ PR rtl-optimization/48263 * optabs.c (expand_binop_directly): Reinstate convert_modes code and original commutative_p handling. Use maybe_gen_insn. Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2011-03-24 09:18:00.000000000 +0000 +++ gcc/optabs.c 2011-03-24 09:36:46.000000000 +0000 @@ -1269,6 +1269,38 @@ expand_binop_directly (enum machine_mode if (!shift_optab_p (binoptab)) xop1 = avoid_expensive_constant (mode1, binoptab, xop1, unsignedp); + /* In case the insn wants input operands in modes different from + those of the actual operands, convert the operands. It would + seem that we don't need to convert CONST_INTs, but we do, so + that they're properly zero-extended, sign-extended or truncated + for their mode. */ + + if (GET_MODE (xop0) != mode0 && mode0 != VOIDmode) + xop0 = convert_modes (mode0, + GET_MODE (xop0) != VOIDmode + ? GET_MODE (xop0) + : mode, + xop0, unsignedp); + + if (GET_MODE (xop1) != mode1 && mode1 != VOIDmode) + xop1 = convert_modes (mode1, + GET_MODE (xop1) != VOIDmode + ? GET_MODE (xop1) + : mode, + xop1, unsignedp); + + /* If operation is commutative, + try to make the first operand a register. + Even better, try to make it the same as the target. + Also try to make the last operand a constant. */ + if (commutative_p + && swap_commutative_operands_with_target (target, xop0, xop1)) + { + swap = xop1; + xop1 = xop0; + xop0 = swap; + } + /* Now, if insn's predicates don't allow our operands, put them into pseudo regs. */ @@ -1291,41 +1323,25 @@ expand_binop_directly (enum machine_mode tmp_mode = mode; create_output_operand (&ops[0], target, tmp_mode); - create_convert_operand_from (&ops[1], xop0, mode, unsignedp); - create_convert_operand_from (&ops[2], xop1, mode, unsignedp); - if (maybe_legitimize_operands (icode, 0, 3, ops)) - { - /* If operation is commutative, - try to make the first operand a register. - Even better, try to make it the same as the target. - Also try to make the last operand a constant. */ - if (commutative_p - && swap_commutative_operands_with_target (ops[0].value, ops[1].value, - ops[2].value)) - { - swap = ops[2].value; - ops[2].value = ops[1].value; - ops[1].value = swap; - } - - pat = GEN_FCN (icode) (ops[0].value, ops[1].value, ops[2].value); - if (pat) + create_input_operand (&ops[1], xop0, mode0); + create_input_operand (&ops[2], xop1, mode1); + pat = maybe_gen_insn (icode, 3, ops); + if (pat) + { + /* If PAT is composed of more than one insn, try to add an appropriate + REG_EQUAL note to it. If we can't because TEMP conflicts with an + operand, call expand_binop again, this time without a target. */ + if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX + && ! add_equal_note (pat, ops[0].value, binoptab->code, + ops[1].value, ops[2].value)) { - /* If PAT is composed of more than one insn, try to add an appropriate - REG_EQUAL note to it. If we can't because TEMP conflicts with an - operand, call expand_binop again, this time without a target. */ - if (INSN_P (pat) && NEXT_INSN (pat) != NULL_RTX - && ! add_equal_note (pat, ops[0].value, binoptab->code, - ops[1].value, ops[2].value)) - { - delete_insns_since (last); - return expand_binop (mode, binoptab, op0, op1, NULL_RTX, - unsignedp, methods); - } - - emit_insn (pat); - return ops[0].value; + delete_insns_since (last); + return expand_binop (mode, binoptab, op0, op1, NULL_RTX, + unsignedp, methods); } + + emit_insn (pat); + return ops[0].value; } delete_insns_since (last); return NULL_RTX;