From patchwork Mon Jun 27 17:33:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 102229 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 47D3AB6F65 for ; Tue, 28 Jun 2011 03:34:05 +1000 (EST) Received: (qmail 5115 invoked by alias); 27 Jun 2011 17:34:03 -0000 Received: (qmail 5055 invoked by uid 22791); 27 Jun 2011 17:34:02 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx3-phx2.redhat.com (HELO mx3-phx2.redhat.com) (209.132.183.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Jun 2011 17:33:45 +0000 Received: from mail06.corp.redhat.com (zmail06.collab.prod.int.phx2.redhat.com [10.5.5.45]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5RHXjF5007937; Mon, 27 Jun 2011 13:33:45 -0400 Date: Mon, 27 Jun 2011 13:33:44 -0400 (EDT) From: Kai Tietz To: gcc-patches@gcc.gnu.org Cc: Richard Guenther Message-ID: <644943966.795848.1309196024947.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com> Subject: {patch tree-ssa-math-opts]: Change searching direction for bswap MIME-Version: 1.0 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 Hello, this is the separated patch for issues noticed by doing type-sinking on bitwise-operations. The tests exposed that bswap pattern-matching searches from top to down for each BB. As it replaces the found match for a bswap in tree, but doesn't know about handling its inserted builtin-swap on pattern-matching for wider-mode bswap, search failed. By reversing search order within BB from last to first, this issue can be fixed. ChangeLog 2011-06-27 Kai Tietz * tree-ssa-math-opts.c (execute_optimize_bswap): Search within BB from last to first. Bootstrapped and regression-tested for x86_64-pc-linux-gnu. Ok for apply? Regards, Kai Index: gcc-head/gcc/tree-ssa-math-opts.c =================================================================== --- gcc-head.orig/gcc/tree-ssa-math-opts.c +++ gcc-head/gcc/tree-ssa-math-opts.c @@ -1820,8 +1820,10 @@ execute_optimize_bswap (void) FOR_EACH_BB (bb) { gimple_stmt_iterator gsi; - +/* for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + */ + for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) { gimple stmt = gsi_stmt (gsi); tree bswap_src, bswap_type;