From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123181 invoked by alias); 9 Dec 2016 13:17:58 -0000 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 Received: (qmail 123167 invoked by uid 89); 9 Dec 2016 13:17:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=52711 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Dec 2016 13:17:49 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F173707; Fri, 9 Dec 2016 05:17:48 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE2EC3F477 for ; Fri, 9 Dec 2016 05:17:47 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [38/67] Move SCALAR_INT_MODE_P out of strict_volatile_bitfield_p References: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> Date: Fri, 09 Dec 2016 13:17:00 -0000 In-Reply-To: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Fri, 09 Dec 2016 12:48:01 +0000") Message-ID: <87wpf9i6md.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2016-12/txt/msg00810.txt.bz2 strict_volatile_bitfield_p returns false for any mode that isn't a scalar integer. This patch moves the check to the caller and makes strict_volatile_bitfield_p take the mode as a scalar_int_mode. The handling of a true return can then also use the mode as a scalar_int_mode. gcc/ 2016-11-24 Richard Sandiford Alan Hayward David Sherwood * expmed.c (strict_volatile_bitfield_p): Change the type of fieldmode to scalar_int_mode. Remove check for SCALAR_INT_MODE_P. (store_bit_field): Check is_a before calling strict_volatile_bitfield_p. (extract_bit_field): Likewise. diff --git a/gcc/expmed.c b/gcc/expmed.c index 3939c3d..f9cdcda 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -514,7 +514,7 @@ lowpart_bit_field_p (unsigned HOST_WIDE_INT bitnum, static bool strict_volatile_bitfield_p (rtx op0, unsigned HOST_WIDE_INT bitsize, unsigned HOST_WIDE_INT bitnum, - machine_mode fieldmode, + scalar_int_mode fieldmode, unsigned HOST_WIDE_INT bitregion_start, unsigned HOST_WIDE_INT bitregion_end) { @@ -527,11 +527,6 @@ strict_volatile_bitfield_p (rtx op0, unsigned HOST_WIDE_INT bitsize, || flag_strict_volatile_bitfields <= 0) return false; - /* Non-integral modes likely only happen with packed structures. - Punt. */ - if (!SCALAR_INT_MODE_P (fieldmode)) - return false; - /* The bit size must not be larger than the field mode, and the field mode must not be larger than a word. */ if (bitsize > modesize || modesize > BITS_PER_WORD) @@ -1050,19 +1045,21 @@ store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, rtx value, bool reverse) { /* Handle -fstrict-volatile-bitfields in the cases where it applies. */ - if (strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, fieldmode, - bitregion_start, bitregion_end)) + scalar_int_mode int_mode; + if (is_a (fieldmode, &int_mode) + && strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, int_mode, + bitregion_start, bitregion_end)) { /* Storing of a full word can be done with a simple store. We know here that the field can be accessed with one single instruction. For targets that support unaligned memory, an unaligned access may be necessary. */ - if (bitsize == GET_MODE_BITSIZE (fieldmode)) + if (bitsize == GET_MODE_BITSIZE (int_mode)) { - str_rtx = adjust_bitfield_address (str_rtx, fieldmode, + str_rtx = adjust_bitfield_address (str_rtx, int_mode, bitnum / BITS_PER_UNIT); if (reverse) - value = flip_storage_order (fieldmode, value); + value = flip_storage_order (int_mode, value); gcc_assert (bitnum % BITS_PER_UNIT == 0); emit_move_insn (str_rtx, value); } @@ -1070,12 +1067,12 @@ store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, { rtx temp; - str_rtx = narrow_bit_field_mem (str_rtx, fieldmode, bitsize, bitnum, + str_rtx = narrow_bit_field_mem (str_rtx, int_mode, bitsize, bitnum, &bitnum); - gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (fieldmode)); + gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (int_mode)); temp = copy_to_reg (str_rtx); if (!store_bit_field_1 (temp, bitsize, bitnum, 0, 0, - fieldmode, value, reverse, true)) + int_mode, value, reverse, true)) gcc_unreachable (); emit_move_insn (str_rtx, temp); @@ -1889,25 +1886,27 @@ extract_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, else mode1 = tmode; - if (strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, mode1, 0, 0)) + scalar_int_mode int_mode; + if (is_a (mode1, &int_mode) + && strict_volatile_bitfield_p (str_rtx, bitsize, bitnum, int_mode, 0, 0)) { - /* Extraction of a full MODE1 value can be done with a simple load. + /* Extraction of a full INT_MODE value can be done with a simple load. We know here that the field can be accessed with one single instruction. For targets that support unaligned memory, an unaligned access may be necessary. */ - if (bitsize == GET_MODE_BITSIZE (mode1)) + if (bitsize == GET_MODE_BITSIZE (int_mode)) { - rtx result = adjust_bitfield_address (str_rtx, mode1, + rtx result = adjust_bitfield_address (str_rtx, int_mode, bitnum / BITS_PER_UNIT); if (reverse) - result = flip_storage_order (mode1, result); + result = flip_storage_order (int_mode, result); gcc_assert (bitnum % BITS_PER_UNIT == 0); return convert_extracted_bit_field (result, mode, tmode, unsignedp); } - str_rtx = narrow_bit_field_mem (str_rtx, mode1, bitsize, bitnum, + str_rtx = narrow_bit_field_mem (str_rtx, int_mode, bitsize, bitnum, &bitnum); - gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (mode1)); + gcc_assert (bitnum + bitsize <= GET_MODE_BITSIZE (int_mode)); str_rtx = copy_to_reg (str_rtx); }