From patchwork Wed Apr 4 00:30:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 150571 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 5B39EB6FF6 for ; Wed, 4 Apr 2012 10:31:12 +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=1334104274; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Cc:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=RwdfhoG a17ZmZnIdmBl/HLoDKX8=; b=fgurXNZKzOaon4QvjVQgyyVKCYzShX7wz1jaMoO 3L5Y5k+YD14mO1Ly/nLyoLusW+oVLyv6TAlRFyLyjCNE0x09nAnIn9DxJhBHuuWB mNehzvTYtDb3MOK2aBp7QrPOmRrIL0EqMcUG9lS1KKgwMQKkf+6xFREmDGdcobMf 9VAw= 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:X-Google-DKIM-Signature:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=L574skc/3PkT2JmxiEVHXVUxejnRnt54zIA+KlCbMzjlotfbLR45kM3tT9LoIE 4QbAmnhQnTOYmbjAu30whefomeqCsWVbBbj+Ds+hi295TnG0BPcnqA/vrfRmx9B6 lJXHV8vcmK7bRxGrUY75rfLV1Ev+bH4QxXeycF00QxIpg=; Received: (qmail 2291 invoked by alias); 4 Apr 2012 00:31:08 -0000 Received: (qmail 2279 invoked by uid 22791); 4 Apr 2012 00:31:07 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-pz0-f49.google.com (HELO mail-pz0-f49.google.com) (209.85.210.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Apr 2012 00:30:48 +0000 Received: by dadq36 with SMTP id q36so265210dad.22 for ; Tue, 03 Apr 2012 17:30:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-system-of-record:x-gm-message-state; bh=8aXycNSi9/V8dkmV8DWSYAtUho0RybOrBxgAzImEXag=; b=puKxQSdZwjHUeHb/qPLNh6LQ8n2Ojp4jBq8cy38/7wDb3avYUGXizElypyZfjiLi1W ssLEJ3jLWmIf0ps93B2pFtWZQ5WYWOPkW+7NWklcfU1kt4BpTmbcwhUt0WxXEBWNT/K8 6t7CfCj52UOKRDVWP16E3oU5alq4AmXlTB5MrCsQ/kh6ARCTivcDc0iggLdFBC9anhhD Lnn8Yy1v80lwAwUVMPh5MRihjJPzg3LsTdBy9ab4g0N8yAcasyhyyiupCoS7Am3uEaYR eU+/V4qrkd1zTcCtDIK4pUVw+j0LIhO1IrVMlRhPxVMIpxAYRM+AfLNo4+vqqp9AKvgS +WEw== Received: by 10.68.190.195 with SMTP id gs3mr6234207pbc.101.1333499447552; Tue, 03 Apr 2012 17:30:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.190.195 with SMTP id gs3mr6234184pbc.101.1333499447425; Tue, 03 Apr 2012 17:30:47 -0700 (PDT) Received: by 10.68.47.166 with HTTP; Tue, 3 Apr 2012 17:30:47 -0700 (PDT) Date: Wed, 4 Apr 2012 08:30:47 +0800 Message-ID: Subject: [google] revert r185948 From: Dehao Chen To: gcc-patches@gcc.gnu.org Cc: Rong Xu X-System-Of-Record: true X-Gm-Message-State: ALoCoQk9BQCJmHolusIbUrWr+a72NbxpDg0NvxOV3G0IbtmtLahFjWX0Ng5vP5TbWZTdzIMiwzzAHXVdRzYBAGCFGZmzxVpFPMmyB8S5xEj3DTWVcWyxrrbb59+DI+XlRDf+iPLTCyvPhrxr7JS+GBXSev2rYagjFw== 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 Revert r185948, which causes regression to major applications. Bootstrapped. OK for google-4_6? Thanks, Dehao Index: gcc/testsuite/gcc.dg/predict-3.c =================================================================== --- gcc/testsuite/gcc.dg/predict-3.c (revision 186128) +++ gcc/testsuite/gcc.dg/predict-3.c (working copy) @@ -10,16 +10,10 @@ int i, ret = 0; for (i = 0; i <= bound; i++) { - if (i < bound - 2) - global += bar (i); - if (i <= bound) - global += bar (i); - if (i + 1 < bound) - global += bar (i); if (i != bound) global += bar (i); } } -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 100.0%" 4 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "loop iv compare heuristics" "profile_estimate"} } */ /* { dg-final { cleanup-tree-dump "profile_estimate" } } */ Index: gcc/testsuite/gcc.dg/predict-4.c =================================================================== --- gcc/testsuite/gcc.dg/predict-4.c (revision 186128) +++ gcc/testsuite/gcc.dg/predict-4.c (working copy) @@ -15,5 +15,5 @@ } } -/* { dg-final { scan-tree-dump "loop iv compare heuristics: 50.0%" "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "loop iv compare heuristics" "profile_estimate"} } */ /* { dg-final { cleanup-tree-dump "profile_estimate" } } */ Index: gcc/testsuite/gcc.dg/predict-1.c =================================================================== --- gcc/testsuite/gcc.dg/predict-1.c (revision 186128) +++ gcc/testsuite/gcc.dg/predict-1.c (working copy) @@ -10,18 +10,10 @@ int i, ret = 0; for (i = 0; i < bound; i++) { - if (i > bound) - global += bar (i); - if (i >= bound + 2) - global += bar (i); if (i > bound - 2) global += bar (i); - if (i + 2 > bound) - global += bar (i); - if (i == 10) - global += bar (i); } } -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 0.0%" 5 "profile_estimate"} } */ +/* { dg-final { scan-tree-dump "loop iv compare heuristics" "profile_estimate"} } */ /* { dg-final { cleanup-tree-dump "profile_estimate" } } */ Index: gcc/testsuite/gcc.dg/predict-5.c =================================================================== --- gcc/testsuite/gcc.dg/predict-5.c (revision 186128) +++ gcc/testsuite/gcc.dg/predict-5.c (working copy) @@ -1,25 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ - -extern int global; - -int bar (int); - -void foo (int base, int bound) -{ - int i, ret = 0; - for (i = base; i <= bound; i++) - { - if (i > base) - global += bar (i); - if (i > base + 1) - global += bar (i); - if (i >= base + 3) - global += bar (i); - if (i - 2 >= base) - global += bar (i); - } -} - -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 100.0%" 4 "profile_estimate"} } */ -/* { dg-final { cleanup-tree-dump "profile_estimate" } } */ Index: gcc/testsuite/gcc.dg/predict-2.c =================================================================== --- gcc/testsuite/gcc.dg/predict-2.c (revision 186128) +++ gcc/testsuite/gcc.dg/predict-2.c (working copy) @@ -5,20 +5,12 @@ int bar(int); -void foo (int base, int bound) +void foo (int bound) { int i, ret = 0; - for (i = base; i < bound; i++) + for (i = 0; i < bound; i++) { - if (i > bound * bound) - global += bar (i); - if (i > bound + 10) - global += bar (i); - if (i <= bound + 10) - global += bar (i); - if (i > base + 10) - global += bar (i); - if (i < base - 10) + if (i > bound * bound ) global += bar (i); } } Index: gcc/testsuite/gcc.dg/predict-6.c =================================================================== --- gcc/testsuite/gcc.dg/predict-6.c (revision 186128) +++ gcc/testsuite/gcc.dg/predict-6.c (working copy) @@ -1,25 +0,0 @@ -/* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */ - -extern int global; - -int bar (int); - -void foo (int base, int bound) -{ - int i, ret = 0; - for (i = base; i <= bound; i++) - { - if (i < base) - global += bar (i); - if (i < base + 1) - global += bar (i); - if (i <= base + 3) - global += bar (i); - if (i - 1 < base) - global += bar (i); - } -} - -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics: 0.0%" 4 "profile_estimate"} } */ -/* { dg-final { cleanup-tree-dump "profile_estimate" } } */ Index: gcc/predict.c =================================================================== --- gcc/predict.c (revision 186128) +++ gcc/predict.c (working copy) @@ -1070,10 +1070,6 @@ bound = get_base_value (bound); if (!bound) return false; - if (TREE_CODE (base) != INTEGER_CST) - base = get_base_value (base); - if (!base) - return false; *loop_invariant = bound; *compare_code = code; @@ -1189,7 +1185,8 @@ return; } - if (!expr_coherent_p(loop_iv_base_var, compare_base)) + if (!expr_coherent_p (loop_bound_var, compare_var) + || loop_iv_base_var != compare_base) return; /* If loop bound, base and compare bound are all constents, we can @@ -1233,52 +1230,34 @@ return; } - if (expr_coherent_p (loop_bound_var, compare_var)) - { - if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR) - && (compare_code == LT_EXPR || compare_code == LE_EXPR)) - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR) - && (compare_code == GT_EXPR || compare_code == GE_EXPR)) - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if (loop_bound_code == NE_EXPR) - { - /* If the loop backedge condition is "(i != bound)", we do - the comparison based on the step of IV: - * step < 0 : backedge condition is like (i > bound) - * step > 0 : backedge condition is like (i < bound) */ - gcc_assert (loop_bound_step != 0); - if (loop_bound_step > 0 - && (compare_code == LT_EXPR - || compare_code == LE_EXPR)) - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else if (loop_bound_step < 0 - && (compare_code == GT_EXPR - || compare_code == GE_EXPR)) - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); - else - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); - } - else - /* The branch is predicted not-taken if loop_bound_code is - opposite with compare_code. */ - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); - } - else if (expr_coherent_p (loop_iv_base_var, compare_var)) - { - /* For cases like: - for (i = s; i < h; i++) - if (i > s + 2) .... - The branch should be predicted taken. */ + if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR) + && (compare_code == LT_EXPR || compare_code == LE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR) + && (compare_code == GT_EXPR || compare_code == GE_EXPR)) + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); + else if (loop_bound_code == NE_EXPR) + { + /* If the loop backedge condition is "(i != bound)", we do + the comparison based on the step of IV: + * step < 0 : backedge condition is like (i > bound) + * step > 0 : backedge condition is like (i < bound) */ + gcc_assert (loop_bound_step != 0); if (loop_bound_step > 0 - && (compare_code == GT_EXPR || compare_code == GE_EXPR)) + && (compare_code == LT_EXPR + || compare_code == LE_EXPR)) predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); else if (loop_bound_step < 0 - && (compare_code == LT_EXPR || compare_code == LE_EXPR)) + && (compare_code == GT_EXPR + || compare_code == GE_EXPR)) predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN); else predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); } + else + /* The branch is predicted not-taken if loop_bound_code is + opposite with compare_code. */ + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN); } /* Predict edge probabilities by exploiting loop structure. */