From patchwork Tue Aug 14 21:11:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 177457 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 445232C0088 for ; Wed, 15 Aug 2012 07:12:19 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1345583540; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:Received:Message-ID:Subject:From:To: Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=IMud/OFSONolr83gpj/O 9QRa/Uc=; b=QF1O2vuPQ6TA3YH1NM/PsZxuT0i/s+SkS7AhXZc9PTz+3AZi/Q/3 DO0Y7KEt0KIkyPXYYJ8cCGHUXMwqg5beSNsRF2HbpU16cd+RUucoFmSr8ZW1P7NK e9jXH8bQfO4PfrAGh+HaQfpTQJJXPcibRMS/wzcgMz7lqMwZX0x3cXQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:Received:Message-ID:Subject:From:To:Cc:Date:Content-Type:Content-Transfer-Encoding:Mime-Version:X-Content-Scanned:x-cbid:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=mvFfgpiQgFLSxbv89RmB8kPjkxTvLcODy76pXV71BgMs8uW2p2O8oAzUFqp1jI gBiGR29v0BOZetTK8jCYc3v+TvipJNZW1dIbboKyYG86g1DUjpLEZwWtoZwKBwRW UesrvKHFHWq4rlcmmJvPjDm/pHuA8vjoScvNI//oXsLg8=; Received: (qmail 12527 invoked by alias); 14 Aug 2012 21:12:15 -0000 Received: (qmail 12519 invoked by uid 22791); 14 Aug 2012 21:12:13 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e9.ny.us.ibm.com (HELO e9.ny.us.ibm.com) (32.97.182.139) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Aug 2012 21:12:00 +0000 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Aug 2012 17:11:57 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 14 Aug 2012 17:11:55 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id DAF026E803F for ; Tue, 14 Aug 2012 17:11:55 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7ELBrrF159550 for ; Tue, 14 Aug 2012 17:11:54 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7ELBr4W018480 for ; Tue, 14 Aug 2012 18:11:53 -0300 Received: from [9.65.219.120] (sig-9-65-219-120.mts.ibm.com [9.65.219.120]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7ELBqt3018022; Tue, 14 Aug 2012 18:11:52 -0300 Message-ID: <1344978713.31850.6.camel@gnopaine> Subject: [PATCH] Fix PR54240 From: "William J. Schmidt" To: gcc-patches@gcc.gnu.org Cc: bergner@vnet.ibm.com, rguenther@suse.de Date: Tue, 14 Aug 2012 16:11:53 -0500 Mime-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12081421-7182-0000-0000-00000248C20F X-IsSubscribed: yes 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 Replace the once vacuously true, and now vacuously false, test for existence of a conditional move instruction for a given mode, with one that actually checks what it's supposed to. Add a test case so we don't miss such things in future. The test is powerpc-specific. It would be good to have an i386 version of the test as well, if someone can help with that. Bootstrapped and tested on powerpc64-unknown-linux-gnu with no new regressions. Ok for trunk? Thanks, Bill gcc: 2012-08-13 Bill Schmidt PR tree-optimization/54240 * tree-ssa-phiopt.c (hoist_adjacent_loads): Correct test for existence of conditional move with given mode. gcc/testsuite: 2012-08-13 Bill Schmidt PR tree-optimization/54240 * gcc.target/powerpc/pr54240.c: New test. Index: gcc/testsuite/gcc.target/powerpc/pr54240.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr54240.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr54240.c (revision 0) @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -misel -fdump-tree-phiopt-details" } */ + +typedef struct s { + int v; + int b; + struct s *l; + struct s *r; +} S; + + +int foo(S *s) +{ + S *this; + S *next; + + this = s; + if (this->b) + next = this->l; + else + next = this->r; + + return next->v; +} + +/* { dg-final { scan-tree-dump "Hoisting adjacent loads" "phiopt1" } } */ +/* { dg-final { cleanup-tree-dump "phiopt1" } } */ Index: gcc/tree-ssa-phiopt.c =================================================================== --- gcc/tree-ssa-phiopt.c (revision 190305) +++ gcc/tree-ssa-phiopt.c (working copy) @@ -1843,7 +1843,8 @@ hoist_adjacent_loads (basic_block bb0, basic_block /* Check the mode of the arguments to be sure a conditional move can be generated for it. */ - if (!optab_handler (cmov_optab, TYPE_MODE (TREE_TYPE (arg1)))) + if (optab_handler (movcc_optab, TYPE_MODE (TREE_TYPE (arg1))) + == CODE_FOR_nothing) continue; /* Both statements must be assignments whose RHS is a COMPONENT_REF. */