From patchwork Mon Sep 19 11:46:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 4181 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8155223EFD for ; Mon, 19 Sep 2011 11:46:39 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 6957EA18098 for ; Mon, 19 Sep 2011 11:46:39 +0000 (UTC) Received: by fxe23 with SMTP id 23so5396016fxe.11 for ; Mon, 19 Sep 2011 04:46:39 -0700 (PDT) Received: by 10.223.61.66 with SMTP id s2mr4951032fah.27.1316432799022; Mon, 19 Sep 2011 04:46:39 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.18.198 with SMTP id y6cs34148lad; Mon, 19 Sep 2011 04:46:38 -0700 (PDT) Received: by 10.150.230.15 with SMTP id c15mr2237528ybh.208.1316432796659; Mon, 19 Sep 2011 04:46:36 -0700 (PDT) Received: from mail-gx0-f178.google.com (mail-gx0-f178.google.com [209.85.161.178]) by mx.google.com with ESMTPS id o12si9584705ybk.105.2011.09.19.04.46.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Sep 2011 04:46:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.161.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=209.85.161.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) smtp.mail=ira.rosen@linaro.org Received: by gxk21 with SMTP id 21so23548885gxk.37 for ; Mon, 19 Sep 2011 04:46:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.38.12 with SMTP id q12mr1998017ybj.447.1316432795941; Mon, 19 Sep 2011 04:46:35 -0700 (PDT) Received: by 10.151.100.9 with HTTP; Mon, 19 Sep 2011 04:46:35 -0700 (PDT) Date: Mon, 19 Sep 2011 14:46:35 +0300 Message-ID: Subject: [patch] Fix PR tree-optmization/50413 From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, When we can't vectorize a certain statement in SLP we mark it as not vectorizable and continue with the analysis. This is wrong when the reason for the failure is that we can't analyze a data-ref, because this way we may miss a data dependence. This patch fails SLP if the data-refs analysis fails. Bootstrapped and tested on powerpc64-suse-linux and i486-linux-gnu. Committed to trunk. The same patch bootstrapped and tested on powerpc64-suse-linux for 4.6. O.K. for 4.6? Thanks, Ira ChangeLog: PR tree-optimization/50413 * tree-vect-data-refs.c (vect_analyze_data_refs): Fail to vectorize a basic block if one of its data-refs can't be analyzed. testsuite/ChangeLog: PR tree-optimization/50413 * g++.dg/vect/vect.exp: Run slp-pr* tests with -fdump-tree-slp-details. Run other tests with -fdump-tree-vect-details. * g++.dg/vect/slp-pr50413.cc: New. Index: ChangeLog =================================================================== --- ChangeLog (revision 178967) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2011-09-19 Ira Rosen + + PR tree-optimization/50413 + * tree-vect-data-refs.c (vect_analyze_data_refs): Fail to vectorize + a basic block if one of its data-refs can't be analyzed. + 2011-09-19 Paul Brook gcc/ Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 178967) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,11 @@ +2011-09-19 Ira Rosen + + PR tree-optimization/50413 + * g++.dg/vect/vect.exp: Run slp-pr* tests with + -fdump-tree-slp-details. Run other tests with + -fdump-tree-vect-details. + * g++.dg/vect/slp-pr50413.cc: New. + 2011-09-18 Dominique d'Humieres Ira Rosen @@ -4,7 +12,7 @@ PR testsuite/50435 * gcc.dg/vect/bb-slp-25.c: Add an if to avoid loop vectorization. Fix underscores around restrict. - + 2011-09-18 Ira Rosen PR tree-optimization/50414 Index: testsuite/g++.dg/vect/vect.exp =================================================================== --- testsuite/g++.dg/vect/vect.exp (revision 178967) +++ testsuite/g++.dg/vect/vect.exp (working copy) @@ -40,9 +40,14 @@ global DEFAULT_VECTCFLAGS set DEFAULT_VECTCFLAGS "" # These flags are used for all targets. -lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fno-vect-cost-model" \ - "-ftree-vectorizer-verbose=4" "-fdump-tree-vect-stats" +lappend DEFAULT_VECTCFLAGS "-O2" "-ftree-vectorize" "-fno-vect-cost-model" +set VECT_SLP_CFLAGS $DEFAULT_VECTCFLAGS + +lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" +lappend VECT_SLP_CFLAGS "-fdump-tree-slp-details" + + # Skip these tests for targets that do not support generating vector # code. Set additional target-dependent vector flags, which can be # overridden by using dg-options in individual tests. @@ -54,8 +59,10 @@ if ![check_vect_support_and_set_flags] { dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,cc,S} ]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.{c,cc,S} ]] \ "" $DEFAULT_VECTCFLAGS +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/slp-pr*.{c,cc,S} ]] \ + "" $VECT_SLP_CFLAGS #### Tests with special options global SAVED_DEFAULT_VECTCFLAGS Index: testsuite/g++.dg/vect/slp-pr50413.cc =================================================================== --- testsuite/g++.dg/vect/slp-pr50413.cc (revision 0) +++ testsuite/g++.dg/vect/slp-pr50413.cc (revision 0) @@ -0,0 +1,185 @@ +/* { dg-require-effective-target vect_int } */ + +typedef unsigned long long UInt64; + +typedef struct struct128 +{ + UInt64 uint64_lower; + UInt64 uint64_upper; +} +STRUCT_128; + +typedef union uint128_bitmap +{ + STRUCT_128 uint128; + + struct + { + UInt64 b00 : 1; + UInt64 b01 : 1; + UInt64 b02 : 1; + UInt64 b03 : 1; + UInt64 b04 : 1; + UInt64 b05 : 1; + UInt64 b06 : 1; + UInt64 b07 : 1; + UInt64 b08 : 1; + UInt64 b09 : 1; + UInt64 b10 : 1; + UInt64 b11 : 1; + UInt64 b12 : 1; + UInt64 b13 : 1; + UInt64 b14 : 1; + UInt64 b15 : 1; + UInt64 b16 : 1; + UInt64 b17 : 1; + UInt64 b18 : 1; + UInt64 b19 : 1; + UInt64 b20 : 1; + UInt64 b21 : 1; + UInt64 b22 : 1; + UInt64 b23 : 1; + UInt64 b24 : 1; + UInt64 b25 : 1; + UInt64 b26 : 1; + UInt64 b27 : 1; + UInt64 b28 : 1; + UInt64 b29 : 1; + UInt64 b30 : 1; + UInt64 b31 : 1; + UInt64 b32 : 1; + UInt64 b33 : 1; + UInt64 b34 : 1; + UInt64 b35 : 1; + UInt64 b36 : 1; + UInt64 b37 : 1; + UInt64 b38 : 1; + UInt64 b39 : 1; + UInt64 b40 : 1; + UInt64 b41 : 1; + UInt64 b42 : 1; + UInt64 b43 : 1; + UInt64 b44 : 1; + UInt64 b45 : 1; + UInt64 b46 : 1; + UInt64 b47 : 1; + UInt64 b48 : 1; + UInt64 b49 : 1; + UInt64 b50 : 1; + UInt64 b51 : 1; + UInt64 b52 : 1; + UInt64 b53 : 1; + UInt64 b54 : 1; + UInt64 b55 : 1; + UInt64 b56 : 1; + UInt64 b57 : 1; + UInt64 b58 : 1; + UInt64 b59 : 1; + UInt64 b60 : 1; + UInt64 b61 : 1; + UInt64 b62 : 1; + UInt64 b63 : 1; + UInt64 b64 : 1; + UInt64 b65 : 1; + UInt64 b66 : 1; + UInt64 b67 : 1; + UInt64 b68 : 1; + UInt64 b69 : 1; + UInt64 b70 : 1; + UInt64 b71 : 1; + UInt64 b72 : 1; + UInt64 b73 : 1; + UInt64 b74 : 1; + UInt64 b75 : 1; + UInt64 b76 : 1; + UInt64 b77 : 1; + UInt64 b78 : 1; + UInt64 b79 : 1; + UInt64 b80 : 1; + UInt64 b81 : 1; + UInt64 b82 : 1; + UInt64 b83 : 1; + UInt64 b84 : 1; + UInt64 b85 : 1; + UInt64 b86 : 1; + UInt64 b87 : 1; + UInt64 b88 : 1; + UInt64 b89 : 1; + UInt64 b90 : 1; + UInt64 b91 : 1; + UInt64 b92 : 1; + UInt64 b93 : 1; + UInt64 b94 : 1; + UInt64 b95 : 1; + UInt64 b96 : 1; + UInt64 b97 : 1; + UInt64 b98 : 1; + UInt64 b99 : 1; + UInt64 b100 : 1; + UInt64 b101 : 1; + UInt64 b102 : 1; + UInt64 b103 : 1; + UInt64 b104 : 1; + UInt64 b105 : 1; + UInt64 b106 : 1; + UInt64 b107 : 1; + UInt64 b108 : 1; + UInt64 b109 : 1; + UInt64 b110 : 1; + UInt64 b111 : 1; + UInt64 b112 : 1; + UInt64 b113 : 1; + UInt64 b114 : 1; + UInt64 b115 : 1; + UInt64 b116 : 1; + UInt64 b117 : 1; + UInt64 b118 : 1; + UInt64 b119 : 1; + UInt64 b120 : 1; + UInt64 b121 : 1; + UInt64 b122 : 1; + UInt64 b123 : 1; + UInt64 b124 : 1; + UInt64 b125 : 1; + UInt64 b126 : 1; + UInt64 b127 : 1; + } + bitmap; +} +UInt128_BITMAP; + +UInt128_BITMAP V; + +template +unsigned char get_bit(CAST value, unsigned char pos) +{ + return ( value & (static_cast(1) << pos) ) != 0; +} + +void shift(unsigned char t) +{ + V.uint128.uint64_lower = (V.uint128.uint64_lower >> 1); + V.bitmap.b63 = V.bitmap.b64; + V.uint128.uint64_upper = (V.uint128.uint64_upper >> 1); + + V.bitmap.b96 = t; +} + +int main() +{ + V.uint128.uint64_lower = 0; + V.uint128.uint64_upper = 0xd4004001; + + UInt64 Kc = 0xDD1A1B8A8A5C2400; + + for (int i = 0; i < 64; i++ ) + { + shift( get_bit( Kc, i) ); + } + + return 0; +} + +/* { dg-final { scan-tree-dump-times "basic block vectorized using SLP" 0 "slp" } } */ +/* { dg-final { cleanup-tree-dump "slp" } } */ + Index: tree-vect-data-refs.c =================================================================== --- tree-vect-data-refs.c (revision 178967) +++ tree-vect-data-refs.c (working copy) @@ -2595,14 +2595,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM); } - if (bb_vinfo) - { - /* Mark the statement as not vectorizable. */ - STMT_VINFO_VECTORIZABLE (stmt_info) = false; - continue; - } - else - return false; + return false; } if (TREE_CODE (DR_BASE_ADDRESS (dr)) == INTEGER_CST) @@ -2610,14 +2603,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)) fprintf (vect_dump, "not vectorized: base addr of dr is a " "constant"); - if (bb_vinfo) - { - /* Mark the statement as not vectorizable. */ - STMT_VINFO_VECTORIZABLE (stmt_info) = false; - continue; - } - else - return false; + return false; } if (TREE_THIS_VOLATILE (DR_REF (dr)))