From patchwork Tue Sep 21 22:44:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 65387 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 83416B70F4 for ; Wed, 22 Sep 2010 08:43:58 +1000 (EST) Received: (qmail 1365 invoked by alias); 21 Sep 2010 22:43:52 -0000 Received: (qmail 1351 invoked by uid 22791); 21 Sep 2010 22:43:49 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, 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; Tue, 21 Sep 2010 22:43:44 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8LMhgEK023273 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Sep 2010 18:43:43 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8LMhfKN026893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Sep 2010 18:43:42 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o8LMiqMg006980 for ; Wed, 22 Sep 2010 00:44:52 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o8LMipub006979 for gcc-patches@gcc.gnu.org; Wed, 22 Sep 2010 00:44:51 +0200 Date: Wed, 22 Sep 2010 00:44:51 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739) Message-ID: <20100921224451.GV1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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! This patch allows optimizing vector | 0 or ^ 0 similarly to similar scalar expressions. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-09-21 Jakub Jelinek PR rtl-optimization/45739 * simplify-rtx.c (simplify_binary_operation_1): Optimize even vector mode | CONST0_RTX (mode) and ^ CONST0_RTX (mode). * gcc.target/i386/pr45739.c: New test. Jakub --- gcc/simplify-rtx.c.jj 2010-09-09 10:16:30.000000000 +0200 +++ gcc/simplify-rtx.c 2010-09-21 13:26:53.000000000 +0200 @@ -2260,7 +2260,7 @@ simplify_binary_operation_1 (enum rtx_co break; case IOR: - if (trueop1 == const0_rtx) + if (trueop1 == CONST0_RTX (mode)) return op0; if (CONST_INT_P (trueop1) && ((INTVAL (trueop1) & GET_MODE_MASK (mode)) @@ -2402,7 +2402,7 @@ simplify_binary_operation_1 (enum rtx_co break; case XOR: - if (trueop1 == const0_rtx) + if (trueop1 == CONST0_RTX (mode)) return op0; if (CONST_INT_P (trueop1) && ((INTVAL (trueop1) & GET_MODE_MASK (mode)) --- gcc/testsuite/gcc.target/i386/pr45739.c.jj 2010-09-21 13:44:05.000000000 +0200 +++ gcc/testsuite/gcc.target/i386/pr45739.c 2010-09-21 13:43:54.000000000 +0200 @@ -0,0 +1,24 @@ +/* PR rtl-optimization/45739 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -msse2" } */ + +#include + +__m128i var; + +void +foo (void) +{ + __m128i zero = _mm_setzero_si128 (); + var = _mm_xor_si128 (zero, var); +} + +void +bar (void) +{ + __m128i zero = _mm_setzero_si128 (); + var = _mm_or_si128 (var, zero); +} + +/* { dg-final { scan-assembler-not "pxor" } } */ +/* { dg-final { scan-assembler-not "por" } } */