From patchwork Fri Mar 4 20:56:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 85441 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 2BA6FB70A6 for ; Sat, 5 Mar 2011 07:56:42 +1100 (EST) Received: (qmail 32009 invoked by alias); 4 Mar 2011 20:56:40 -0000 Received: (qmail 32000 invoked by uid 22791); 4 Mar 2011 20:56:38 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CP, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 04 Mar 2011 20:56:34 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p24KuWUG008248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 4 Mar 2011 15:56:32 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p24KuV9S009710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 4 Mar 2011 15:56:32 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p24KuVrG030766 for ; Fri, 4 Mar 2011 21:56:31 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p24KuUIb030763 for gcc-patches@gcc.gnu.org; Fri, 4 Mar 2011 21:56:30 +0100 Date: Fri, 4 Mar 2011 21:56:30 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Teach var-tracking about some targets setmem/movmem patterns (PR debug/47991) Message-ID: <20110304205630.GM30899@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi! s390 uses (set (mem:BLK ...) (reg:DI ...)) pattern for setmem, but even i?86 uses (set (mem:BLK ...) (const_int ...)). Telling var-tracking in that case that (mem:BLK) has the (reg:DI) resp. (const_int) value is wrong and leads to mode mismatches. So, the following patch fixes it by returning NULL from find_use_val in that case (cselib_lookup on BLKmode MEM always returns NULL, but in this routine we are returning cselib_lookup result of the SET_SRC which in this case has a different mode). Bootstrapped/regtested on x86_64-linux and i686-linux and tested on the provided testcase in s390x-linux cross. Ok for trunk? 2011-03-04 Jakub Jelinek PR debug/47991 * var-tracking.c (find_use_val): Return NULL for cui->sets && cui->store_p BLKmode MEMs. * gcc.dg/pr47991.c: New test. Jakub --- gcc/var-tracking.c.jj 2011-02-15 15:42:27.000000000 +0100 +++ gcc/var-tracking.c 2011-03-04 19:08:15.000000000 +0100 @@ -4784,12 +4784,19 @@ find_use_val (rtx x, enum machine_mode m if (cui->sets) { /* This is called after uses are set up and before stores are - processed bycselib, so it's safe to look up srcs, but not + processed by cselib, so it's safe to look up srcs, but not dsts. So we look up expressions that appear in srcs or in dest expressions, but we search the sets array for dests of stores. */ if (cui->store_p) { + /* Some targets represent memset and memcpy patterns + by (set (mem:BLK ...) (reg:[QHSD]I ...)) or + (set (mem:BLK ...) (const_int ...)) or + (set (mem:BLK ...) (mem:BLK ...)). Don't return anything + in that case, otherwise we end up with mode mismatches. */ + if (mode == BLKmode && MEM_P (x)) + return NULL; for (i = 0; i < cui->n_sets; i++) if (cui->sets[i].dest == x) return cui->sets[i].src_elt; --- gcc/testsuite/gcc.dg/pr47991.c.jj 2011-03-04 19:23:06.000000000 +0100 +++ gcc/testsuite/gcc.dg/pr47991.c 2011-03-04 19:25:26.000000000 +0100 @@ -0,0 +1,25 @@ +/* PR debug/47991 */ +/* { dg-do compile } */ +/* { dg-options "-g -Os" } */ + +typedef __SIZE_TYPE__ size_t; +extern inline __attribute__ ((__always_inline__)) +void * +memset (void *x, int y, size_t z) +{ + return __builtin___memset_chk (x, y, z, __builtin_object_size (x, 0)); +} + +void +foo (unsigned char *x, unsigned char *y, unsigned char *z, + unsigned char *w, unsigned int v, int u, int t) +{ + int i; + for (i = 0; i < t; i++) + { + memset (z, x[0], v); + memset (w, y[0], v); + x += u; + } + __builtin_memcpy (z, x, u); +}