From patchwork Sun Jul 14 18:55:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1131766 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-505068-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 45mwpr6KRzz9s4Y for ; Mon, 15 Jul 2019 04:55:43 +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=bFUxIi07SMcVAkHbfIlZPXajGb8Ye+m06I8sFwk2dKb31+ P7hvFhRump2ZNt/SIZL18U1dbLUVouDlL3AGbt3HlDTW6HuXsBIlTlMmCkFRRuTb gIFI55dXwQOXsXk26B9i9j18vVpJv9ktPhNOJy5qBOJNzqRZxRRAONicx4Qw8= 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=l9WxE9LWQlVIDV5FKdkOCTiqIcw=; b=k+eL+Kzlu1DB9PO1tt9u dTMDA2e8grPQWM8hBUOLgbBfUUbYSl7f6gaI+ryfFIrYw5mWMl7PT6uN3gY4/2al rtfop0YB1mJ/6Ep5Svzin+Ksp8F/CF8OIC9DK3PZmaWZN7b7OSIjJKJFS0u6kUd8 TyoJxYX+bezk0+YN3A/88jw= Received: (qmail 26548 invoked by alias); 14 Jul 2019 18:55:35 -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 26540 invoked by uid 89); 14 Jul 2019 18:55:35 -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=sk:nonimme X-HELO: mail-ed1-f44.google.com Received: from mail-ed1-f44.google.com (HELO mail-ed1-f44.google.com) (209.85.208.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 14 Jul 2019 18:55:33 +0000 Received: by mail-ed1-f44.google.com with SMTP id r12so13363828edo.5 for ; Sun, 14 Jul 2019 11:55:33 -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=4UqBuiilcmF5TAt6r4p5iUGyVD7a+Zypr3IiDu620/k=; b=O5VXPnps5A9iyTmLPioMDAzSRXyCYsQ150J0OZHYZyLu8LNzEdsI3Zvh2fLXboj1OV mwQPxvhev51/Ws9iCUp+VVOKxos2EymdB2rT1ik3Auqk6qUH5/QDMMfmMTfezKov89dN XaRpwgjxqQ/BSlk0nP971VUYciFEHbOp3KPzUXiwANGLABMQFCUEjUhv+E+DCNrjvKdz g1Zc0fs6N3IHRL0+wMPaGBrYf3tmfwgvhCE9QiLYneQkP+eOe7bXP8A4fE5IMkkfpZV0 cSdsdOP+7cQqCYlFsEkgISfeoycgN1OJk1R+KlEd/cWyhbrYLEtTNlcM+YZtLn+NjAm9 Qp1Q== MIME-Version: 1.0 From: Uros Bizjak Date: Sun, 14 Jul 2019 20:55:20 +0200 Message-ID: Subject: [PATCH, i386]: Adjust operand predicate of several test instructions To: "gcc-patches@gcc.gnu.org" Operand constraints accept only register and immediate operands, so adjust operand predicate to reject memory operands. 2019-07-14 Uroš Bizjak * config/i386/i386.md (nonmemory_szext_operand): New mode attribute. (test_ccno_1): Macroize insn pattern from testsi_ccno_1 and testdi_ccno_1 using SWI48 mode attribute. (*testdi_1): Use x86_64_szext_nonmemory_operand instead of x86_64_szext_general_operand. (*testqi_1_maybe_si): Use nonmemory_operand instead of general_operand. (*test_1): Use nonmemory_szext_operand mode attribute instead of genera_operand mode attribute. 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 db5fa9ae3cae..58797baa6dc5 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -1122,6 +1122,12 @@ (SI "x86_64_szext_general_operand") (DI "x86_64_szext_general_operand")]) +(define_mode_attr nonmemory_szext_operand + [(QI "nonmemory_operand") + (HI "nonmemory_operand") + (SI "x86_64_szext_nonmemory_operand") + (DI "x86_64_szext_nonmemory_operand")]) + ;; Immediate operand predicate for integer modes. (define_mode_attr immediate_operand [(QI "immediate_operand") @@ -8118,11 +8124,12 @@ ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al. ;; Note that this excludes ah. -(define_expand "testsi_ccno_1" +(define_expand "test_ccno_1" [(set (reg:CCNO FLAGS_REG) (compare:CCNO - (and:SI (match_operand:SI 0 "nonimmediate_operand") - (match_operand:SI 1 "x86_64_nonmemory_operand")) + (and:SWI48 + (match_operand:SWI48 0 "nonimmediate_operand") + (match_operand:SWI48 1 "")) (const_int 0)))]) (define_expand "testqi_ccz_1" @@ -8131,23 +8138,14 @@ (match_operand:QI 1 "nonmemory_operand")) (const_int 0)))]) -(define_expand "testdi_ccno_1" - [(set (reg:CCNO FLAGS_REG) - (compare:CCNO - (and:DI (match_operand:DI 0 "nonimmediate_operand") - (match_operand:DI 1 "x86_64_szext_general_operand")) - (const_int 0)))] - "TARGET_64BIT && !(MEM_P (operands[0]) && MEM_P (operands[1]))") - (define_insn "*testdi_1" [(set (reg FLAGS_REG) (compare (and:DI (match_operand:DI 0 "nonimmediate_operand" "%!*a,r,!*a,r,rm") - (match_operand:DI 1 "x86_64_szext_general_operand" "Z,Z,e,e,re")) + (match_operand:DI 1 "x86_64_szext_nonmemory_operand" "Z,Z,e,e,re")) (const_int 0)))] - "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode) - && !(MEM_P (operands[0]) && MEM_P (operands[1]))" + "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)" "@ test{l}\t{%k1, %k0|%k0, %k1} test{l}\t{%k1, %k0|%k0, %k1} @@ -8163,12 +8161,12 @@ (compare (and:QI (match_operand:QI 0 "nonimmediate_operand" "%!*a,q,qm,r") - (match_operand:QI 1 "general_operand" "n,n,qn,n")) + (match_operand:QI 1 "nonmemory_operand" "n,n,qn,n")) (const_int 0)))] - "!(MEM_P (operands[0]) && MEM_P (operands[1])) - && ix86_match_ccmode (insn, - CONST_INT_P (operands[1]) - && INTVAL (operands[1]) >= 0 ? CCNOmode : CCZmode)" + + "ix86_match_ccmode (insn, + CONST_INT_P (operands[1]) + && INTVAL (operands[1]) >= 0 ? CCNOmode : CCZmode)" { if (which_alternative == 3) { @@ -8188,10 +8186,9 @@ (compare (and:SWI124 (match_operand:SWI124 0 "nonimmediate_operand" "%!*a,,m") - (match_operand:SWI124 1 "" ",,")) + (match_operand:SWI124 1 "" ",,")) (const_int 0)))] - "ix86_match_ccmode (insn, CCNOmode) - && !(MEM_P (operands[0]) && MEM_P (operands[1]))" + "ix86_match_ccmode (insn, CCNOmode)" "test{}\t{%1, %0|%0, %1}" [(set_attr "type" "test") (set_attr "modrm" "0,1,1")