From patchwork Tue Jul 19 12:15:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 105468 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 13DFAB6F8E for ; Tue, 19 Jul 2011 22:16:03 +1000 (EST) Received: (qmail 20449 invoked by alias); 19 Jul 2011 12:16:00 -0000 Received: (qmail 20433 invoked by uid 22791); 19 Jul 2011 12:15:58 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-fx0-f49.google.com (HELO mail-fx0-f49.google.com) (209.85.161.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Jul 2011 12:15:37 +0000 Received: by fxd20 with SMTP id 20so6382186fxd.22 for ; Tue, 19 Jul 2011 05:15:36 -0700 (PDT) Received: by 10.223.7.8 with SMTP id b8mr12120465fab.19.1311077736250; Tue, 19 Jul 2011 05:15:36 -0700 (PDT) Received: from richards-thinkpad (gbibp9ph1--blueice3n2.emea.ibm.com [195.212.29.84]) by mx.google.com with ESMTPS id h10sm1623789fai.43.2011.07.19.05.15.35 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Jul 2011 05:15:35 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: PR 49742: call lhs being ignored Date: Tue, 19 Jul 2011 13:15:33 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) 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 In 49742, we have: vect_array.21 = LOAD_LANES (MEM[(int[512] *)vect_pin.17_56]); vect_var_.22_58 = vect_array.21[0]; predcom doesn't think that there are any dependencies between the two statements, so hoists the second one as an invariant. This in turn is because get_references_in_stmt ignores the lhs of calls. Tested on x86_64-linux-gnu and arm-linux-gnueabi. OK to install? Richard gcc/ PR tree-optimization/49742 * tree-data-ref.c (get_references_in_stmt): Treat the lhs of a call as a potential write. Index: gcc/tree-data-ref.c =================================================================== --- gcc/tree-data-ref.c 2011-07-19 10:53:10.000000000 +0100 +++ gcc/tree-data-ref.c 2011-07-19 13:08:12.000000000 +0100 @@ -4158,33 +4158,37 @@ get_references_in_stmt (gimple stmt, VEC ref->pos = op1; ref->is_read = true; } - - if (DECL_P (*op0) - || (REFERENCE_CLASS_P (*op0) && get_base_address (*op0))) - { - ref = VEC_safe_push (data_ref_loc, heap, *references, NULL); - ref->pos = op0; - ref->is_read = false; - } } else if (stmt_code == GIMPLE_CALL) { - unsigned i, n = gimple_call_num_args (stmt); + unsigned i, n; + op0 = gimple_call_lhs_ptr (stmt); + n = gimple_call_num_args (stmt); for (i = 0; i < n; i++) { - op0 = gimple_call_arg_ptr (stmt, i); + op1 = gimple_call_arg_ptr (stmt, i); - if (DECL_P (*op0) - || (REFERENCE_CLASS_P (*op0) && get_base_address (*op0))) + if (DECL_P (*op1) + || (REFERENCE_CLASS_P (*op1) && get_base_address (*op1))) { ref = VEC_safe_push (data_ref_loc, heap, *references, NULL); - ref->pos = op0; + ref->pos = op1; ref->is_read = true; } } } + else + return clobbers_memory; + if (*op0 + && (DECL_P (*op0) + || (REFERENCE_CLASS_P (*op0) && get_base_address (*op0)))) + { + ref = VEC_safe_push (data_ref_loc, heap, *references, NULL); + ref->pos = op0; + ref->is_read = false; + } return clobbers_memory; }