From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60429 invoked by alias); 4 Apr 2016 12:57:06 -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 59678 invoked by uid 89); 4 Apr 2016 12:57:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=ud, host_wide_int, HOST_WIDE_INT, sk:GET_MOD X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 04 Apr 2016 12:56:55 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 36E1FABB4; Mon, 4 Apr 2016 12:56:51 +0000 (UTC) Date: Mon, 04 Apr 2016 12:57:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek , iant@google.com Subject: [PATCH][GCC 7] Remove broken path in extract_bit_field_1 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-04/txt/msg00165.txt.bz2 r141430 as a fix for PR37870 added a memory fallback to extract_bit_field_1 and another case punning through a larger integer mode (as suggested by Ian). That path is broken as it happily creates (set (subreg:XF (reg:TI ..)) (...)) on i?86 when we optimize the added testcase unsigned int bar (long double x) { union { struct { char a[8]; unsigned int b:7; } c; long double d; } u; u.d = x; return u.c.b; } on GIMPLE to bar (long double x) { unsigned int _3; _4; ;; basic block 2, loop depth 0 ;; pred: ENTRY _4 = BIT_FIELD_REF ; _3 = (unsigned int) _4; return _3; Bootstrapped and tested on x86_64-unknown-linux-gnu (also with -m32) and the code replaced with a gcc_unreachable (). I don't see how a subreg can be ever valid as it will be necessarily converting to a non-integer mode of different size (otherwise int_mode_for_mode would have returned non-BLKmode). I can't think of a condition that would need to be satisfied where the subreg would be valid either. Ok for GCC 7? (it'll be done as part of said GIMPLE optimization). The testcase gcc.target/i386/pr37870.c will already ICE with that patch, so no additional testcase. Thanks, Richard. 2016-04-04 Richard Biener PR middle-end/37870 * expmed.c (extract_bit_field_1): Remove broken case using a wider MODE_INT mode. Index: gcc/expmed.c =================================================================== --- gcc/expmed.c (revision 234708) +++ gcc/expmed.c (working copy) @@ -1647,17 +1647,6 @@ extract_bit_field_1 (rtx str_rtx, unsign if (GET_CODE (op0) == SUBREG) op0 = force_reg (imode, op0); } - else if (REG_P (op0)) - { - rtx reg, subreg; - imode = smallest_mode_for_size (GET_MODE_BITSIZE (GET_MODE (op0)), - MODE_INT); - reg = gen_reg_rtx (imode); - subreg = gen_lowpart_SUBREG (GET_MODE (op0), reg); - emit_move_insn (subreg, op0); - op0 = reg; - bitnum += SUBREG_BYTE (subreg) * BITS_PER_UNIT; - } else { HOST_WIDE_INT size = GET_MODE_SIZE (GET_MODE (op0));