From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1284 invoked by alias); 5 Jul 2011 20:13:37 -0000 Received: (qmail 1275 invoked by uid 22791); 5 Jul 2011 20:13:36 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Jul 2011 20:13:22 +0000 Received: (qmail 15497 invoked from network); 5 Jul 2011 20:13:22 -0000 Received: from unknown (HELO ?84.152.173.78?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 Jul 2011 20:13:22 -0000 Message-ID: <4E13705B.9080206@codesourcery.com> Date: Tue, 05 Jul 2011 21:35:00 -0000 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110505 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Richard Henderson CC: GCC Patches Subject: Re: [2/11] Neater tests for signbits References: <4E0E0310.60406@codesourcery.com> <4E0E03FF.2090405@codesourcery.com> <4E136149.2000802@redhat.com> In-Reply-To: <4E136149.2000802@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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-07/txt/msg00310.txt.bz2 On 07/05/11 21:08, Richard Henderson wrote: > On 07/01/2011 10:29 AM, Bernd Schmidt wrote: >> * cse.c (find_comparison_args): Use val_mode_signbit_set_p. >> * simplify-rtx.c (mode_signbit_p): Use GET_MODE_PRECISION. >> (val_mode_signbit_p, val_mode_signbit_set_p): New functions. >> (simplify_const_unary_operation, simplify_binary_operation_1, >> simplify_const_binary_operation, >> simplify_const_relational_operation): Use them. Use >> GET_MODE_MASK for masking and sign-extensions. >> * combine.c (set_nonzero_bits_and_sign_copies, simplify_set, >> combine_simplify_rtx, force_to_mode, reg_nonzero_bits_for_combine, >> simplify_shift_const_1, simplify_comparison): Likewise. >> * expr.c (convert_modes): Likewise. >> * rtlanal.c (nonzero_bits1, canonicalize_condition): Likewise. >> * expmed.c (emit_cstore, emit_store_flag_1, emit_store_flag): >> Likewise. >> * rtl.h (val_mode_signbit_p, val_mode_signbit_set_p): Declare. > > Ok, but, > >> /* We must sign or zero-extend in this case. Start by >> zero-extending, then sign extend if we need to. */ >> - val &= ((HOST_WIDE_INT) 1 << width) - 1; >> + val &= GET_MODE_MASK (oldmode); >> if (! unsignedp >> - && (val & ((HOST_WIDE_INT) 1 << (width - 1)))) >> - val |= (HOST_WIDE_INT) (-1) << width; >> + && val_signbit_known_set_p (oldmode, val)) >> + val |= ~GET_MODE_MASK (oldmode); >> >> return gen_int_mode (val, mode); > > Shouldn't that sign-extension already be done by gen_int_mode? I think that's a different case than the simplify_rtx one in patch #3. Here, we're extending from oldmode, while gen_int_mode takes care of the extension for mode. Thanks for the reviews! Bernd