From patchwork Wed Aug 4 16:30:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 60871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5DFFB1007D3 for ; Thu, 5 Aug 2010 02:30:53 +1000 (EST) Received: (qmail 21702 invoked by alias); 4 Aug 2010 16:30:50 -0000 Received: (qmail 21685 invoked by uid 22791); 4 Aug 2010 16:30:48 -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; Wed, 04 Aug 2010 16:30:43 +0000 Received: (qmail 22286 invoked from network); 4 Aug 2010 16:30:41 -0000 Received: from unknown (HELO ?84.152.241.194?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 4 Aug 2010 16:30:41 -0000 Message-ID: <4C5995A6.8050701@codesourcery.com> Date: Wed, 04 Aug 2010 18:30:30 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.7) Gecko/20100724 Thunderbird/3.1.1 MIME-Version: 1.0 To: "H.J. Lu" CC: Paolo Bonzini , GCC Patches , Richard Earnshaw Subject: Re: Combiner fixes References: <4C572CA0.3040802@codesourcery.com> <4C57C416.70504@gnu.org> <4C582BD8.3080306@codesourcery.com> In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 08/04/2010 05:39 PM, H.J. Lu wrote: > This caused: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45182 This seems to be a latent bug. We call make_compound_operation on (plus:V2DI (ashift:V2DI (reg:V2DI 137) (const_int 2 [0x2])) (reg:V2DI 145)) and try to convert the shift into a multiplication, and trunc_int_for_mode fails when asked to do something with V2DImode. I think it's best not to do any of that for anything but plain integer modes. Ok if tests pass? Bernd PR middle-end/45182 * combine.c (make_compound_operation): Don't try to convert shifts into multiplications for modes that aren't SCALAR_INT_MODE_P. PR middle-end/45182 * gcc.c-torture/compile/pr45182.c: New test. Index: combine.c =================================================================== --- combine.c (revision 162849) +++ combine.c (working copy) @@ -7093,7 +7093,9 @@ make_compound_operation (rtx x, enum rtx address, we stay there. If we have a comparison, set to COMPARE, but once inside, go back to our default of SET. */ - next_code = (code == MEM || code == PLUS || code == MINUS ? MEM + next_code = (code == MEM ? MEM + : ((code == PLUS || code == MINUS) + && SCALAR_INT_MODE_P (mode)) ? MEM : ((code == COMPARE || COMPARISON_P (x)) && XEXP (x, 1) == const0_rtx) ? COMPARE : in_code == COMPARE ? SET : in_code); @@ -7127,8 +7129,8 @@ make_compound_operation (rtx x, enum rtx case PLUS: lhs = XEXP (x, 0); rhs = XEXP (x, 1); - lhs = make_compound_operation (lhs, MEM); - rhs = make_compound_operation (rhs, MEM); + lhs = make_compound_operation (lhs, next_code); + rhs = make_compound_operation (rhs, next_code); if (GET_CODE (lhs) == MULT && GET_CODE (XEXP (lhs, 0)) == NEG && SCALAR_INT_MODE_P (mode)) { @@ -7157,8 +7159,8 @@ make_compound_operation (rtx x, enum rtx case MINUS: lhs = XEXP (x, 0); rhs = XEXP (x, 1); - lhs = make_compound_operation (lhs, MEM); - rhs = make_compound_operation (rhs, MEM); + lhs = make_compound_operation (lhs, next_code); + rhs = make_compound_operation (rhs, next_code); if (GET_CODE (rhs) == MULT && GET_CODE (XEXP (rhs, 0)) == NEG && SCALAR_INT_MODE_P (mode)) { Index: testsuite/gcc.c-torture/compile/pr45182.c =================================================================== --- testsuite/gcc.c-torture/compile/pr45182.c (revision 0) +++ testsuite/gcc.c-torture/compile/pr45182.c (revision 0) @@ -0,0 +1,10 @@ +typedef struct TypHeader { + struct TypHeader ** ptr; +} *TypHandle; +void PlainRange (TypHandle hdList, long lenList, long low, long inc) +{ + long i; + for (i = 1; i <= lenList; i++ ) + (((TypHandle*)((hdList)->ptr))[i] = (((TypHandle) (((long)(low + (i-1) * +inc) << 2) + 1)))); +}