From patchwork Tue Jul 16 17:19:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1132885 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505160-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="dL10gwBE"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MPOxwL+D"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45p6bd5GSqz9s3l for ; Wed, 17 Jul 2019 03:20:12 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=kTDHvoiEG1Lz8kqNXsboQp5CqpDQqmdBpYZWfzONiEi81j Q9gbOCsWWwaQx3H+oWadDzng2HfjxrE0jgDaaF9RM3ckI6uQgyKHUMJ/FSVyA0BY xPhVyfO8EiYVQjfLJ3+C+ShzbO9jwD6dgA3lol9jZU3Xige1gu31Wf0wfUDPI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=5nUO8Jd6p4svPqac4pYxRGghHz8=; b=dL10gwBES6HDUuOkaeeC pVg2IS6TtbSgHKURC+kprKvGAgPak3mzeJsGOFTrF54bxqtdMDTBgospaEa2w20I vH+CDgeAaGerdmdJ5GRr29lcFyS7gH9Hwr25YI3EeNO1vncXQHg9pZo5ZylR/nQZ 9RHlL6bpWFFaDcsjr6LEBLw= Received: (qmail 80255 invoked by alias); 16 Jul 2019 17:20:04 -0000 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 Received: (qmail 80246 invoked by uid 89); 16 Jul 2019 17:20:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-ed1-f50.google.com Received: from mail-ed1-f50.google.com (HELO mail-ed1-f50.google.com) (209.85.208.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Jul 2019 17:20:02 +0000 Received: by mail-ed1-f50.google.com with SMTP id e3so21135992edr.10 for ; Tue, 16 Jul 2019 10:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=4riEPtvBnhliHOuKNTqiG4Y4j3wdwhvaChd6UBA3d94=; b=MPOxwL+DajRjD/xJiuGkcVJ+hnNGOhQzUFuxhT0qE4Bo0xvEwdtIcrkWdaHpKrQ+cu Bk/UA3Fdqj305OHIjdP5VnaMsCjTF96xjPKrOaZmK2dzkwlpakKTeDgVhspdX1VjX9J3 PQgCDK4zpAI9Twx78bu4V2qJxmKePSSySYqis0GZ/t+72wrtREwHKX1q8GFUXmpzfK0f P37CzaWx0q/mfQL9LTer45ku8QThuX7+vWnLbf3D1khyIU+BcoayLUTQ2fcSLNQCW3CM 7lVEOAo8ZJB/izLvX14VOUcV/MlCbG4u6aBK57pC79V/ryb8XsGbWINjw0RtoiiKLWIt AkoA== MIME-Version: 1.0 From: Uros Bizjak Date: Tue, 16 Jul 2019 19:19:49 +0200 Message-ID: Subject: [PATCH, i386]: Further fixes/improvements for TEST patterns To: "gcc-patches@gcc.gnu.org" 2019-07-16 Uroš Bizjak * config/i386/i386.md (*testdi_1): Match CCZmode for constants that might have the SImode sign bit set. (*testqi_1_maybe_si): Remove "!" constraint modifier. Use correct constraints for pentium pairing. (*test_1): Ditto. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 410731fda251..eb32d7c1d2a5 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -8134,18 +8134,31 @@ (define_expand "testqi_ccz_1" [(set (reg:CCZ FLAGS_REG) - (compare:CCZ (and:QI (match_operand:QI 0 "nonimmediate_operand") - (match_operand:QI 1 "nonmemory_operand")) - (const_int 0)))]) + (compare:CCZ + (and:QI + (match_operand:QI 0 "nonimmediate_operand") + (match_operand:QI 1 "nonmemory_operand")) + (const_int 0)))]) (define_insn "*testdi_1" [(set (reg FLAGS_REG) (compare - (and:DI - (match_operand:DI 0 "nonimmediate_operand" "%r,rm") - (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,re")) + (and:DI + (match_operand:DI 0 "nonimmediate_operand" "%r,rm") + (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,re")) (const_int 0)))] - "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" + "TARGET_64BIT + && ix86_match_ccmode + (insn, + /* If we are going to emit testl instead of testq, and the operands[1] + constant might have the SImode sign bit set, make sure the sign + flag isn't tested, because the instruction will set the sign flag + based on bit 31 rather than bit 63. If it isn't CONST_INT, + conservatively assume it might have bit 31 set. */ + (satisfies_constraint_Z (operands[1]) + && (!CONST_INT_P (operands[1]) + || val_signbit_known_set_p (SImode, INTVAL (operands[1])))) + ? CCZmode : CCNOmode)" "@ test{l}\t{%k1, %k0|%k0, %k1} test{q}\t{%1, %0|%0, %1}" @@ -8154,12 +8167,11 @@ (define_insn "*testqi_1_maybe_si" [(set (reg FLAGS_REG) - (compare + (compare (and:QI - (match_operand:QI 0 "nonimmediate_operand" "%!*a,q,qm,r") - (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n")) + (match_operand:QI 0 "nonimmediate_operand" "%qm,*a,qm,r") + (match_operand:QI 1 "nonmemory_operand" "q,n,n,n")) (const_int 0)))] - "ix86_match_ccmode (insn, CONST_INT_P (operands[1]) && INTVAL (operands[1]) >= 0 ? CCNOmode : CCZmode)" @@ -8174,20 +8186,20 @@ } [(set_attr "type" "test") (set_attr "mode" "QI,QI,QI,SI") - (set_attr "pent_pair" "uv,np,uv,np")]) + (set_attr "pent_pair" "uv,uv,np,np")]) (define_insn "*test_1" [(set (reg FLAGS_REG) (compare - (and:SWI124 - (match_operand:SWI124 0 "nonimmediate_operand" "%!*a,,m") - (match_operand:SWI124 1 "" ",,")) + (and:SWI124 + (match_operand:SWI124 0 "nonimmediate_operand" "%m,*a,m") + (match_operand:SWI124 1 "" ",,")) (const_int 0)))] "ix86_match_ccmode (insn, CCNOmode)" "test{}\t{%1, %0|%0, %1}" [(set_attr "type" "test") (set_attr "mode" "") - (set_attr "pent_pair" "uv,np,uv")]) + (set_attr "pent_pair" "uv,uv,np")]) (define_expand "testqi_ext_1_ccno" [(set (reg:CCNO FLAGS_REG)