From patchwork Mon Jul 15 20:37:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 1132275 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-505108-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="lH9YyVcg"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lv3/OnMf"; 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 45nb2F6txGz9sBt for ; Tue, 16 Jul 2019 06:37:53 +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=clu+ydptpXL+3lIqeXGm9QKXuCUVqIUcNP8x2LqtrpeZ0A 84V16ueHtjrI8pBguZOq8l1Ao9RhKVaK2JjSk/nH4f4vZGWkkiNhITZE8cqs/8Wu VWU8aQ1/+436iNJTA1+Kev3hrgq2G2I6+oPexOxm/KrbG1HFkyhtMbsFi99Zk= 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=rYD1b/Ai82oetJc1/SNo1BcbjxE=; b=lH9YyVcgj2byRxT4lOjJ WRL96uFbalAKGfs+06kXuvn3eAOAwY78O86vly3PpIXu50hJtenwo/V+t4glaSBT 35fR5aLf2Kz/5u/PaVJWY7X/Bc1iugCC9y5ZguO7xD0b/lDXJttoiWtSxWKcFJBF hWzX0VMAKtAdqFW3nY/qdFQ= Received: (qmail 102348 invoked by alias); 15 Jul 2019 20:37:45 -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 102340 invoked by uid 89); 15 Jul 2019 20:37:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=calculated X-HELO: mail-ed1-f51.google.com Received: from mail-ed1-f51.google.com (HELO mail-ed1-f51.google.com) (209.85.208.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 15 Jul 2019 20:37:44 +0000 Received: by mail-ed1-f51.google.com with SMTP id w13so16764852eds.4 for ; Mon, 15 Jul 2019 13:37:43 -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=E2sC+bygG9qDaAubbJwQiLb0/DsMWUBpYcdTuVf8Clc=; b=lv3/OnMffC7iEVTOGmnGb4ufHSZx+uOdzoZV4sRAmrViPgA8Fx2jj9kaCH85Bl4jX9 tx0B+Bn8wfUQ8v9gIP2OPSaasVAIKe3dc0fnGl7jg739fbpz+1jB0UoESShdEZfifCTk pw+fwGwPrr38E/qiv/TUYlAPMpgjORhOi0EyoQVYazL+H8IPL6CiAt6BimhDf5/ViYi1 XyRLvgd579oyNqt4dXWSEyAHkd6abcP1I0jChuzWFFoBRzHB5EIMMyMkwlOOyPi8RRwG r8u/9kQqqZ1Kz/5TfeKLijGJRS7lrCJ3iw/bpDGx1PQEOy08vZUHclXOgTqMVZLQX2+j 8+ig== MIME-Version: 1.0 From: Uros Bizjak Date: Mon, 15 Jul 2019 22:37:30 +0200 Message-ID: Subject: [PATCH, i386]: Cleanup TEST insn patterns To: "gcc-patches@gcc.gnu.org" Attached patch cleans TEST insn patterns by removing unneeded alternatives from *testdi_1 (these were cargo-culted from *testsi_1, where they are used to describe pentium pairing, but pentium is not a 64bit target). The patch also removes manual definition of modrm attribute. This attribute is nowadays correctly calculated in a generic way for all "test" type insns also when AX register is used. Additionally, the patch changes test_ccno_1 insn name to a parametrized insn name and uses a generic gen_extend_insn infrastructure instead of calling named insn pattern directly. 2019-07-15 Uroš Bizjak * config/i386/i386.md (@test_ccno_1): Rename from test_ccno_1. (*testdi_1): Remove redundant alternatives. Remove modrm attribute. (*testqi_1_maybe_si): Remove modrm attribute. (*test_1): Ditto. * config/i386/i386-expand.c (ix86_split_idivmod): Use gen_test_ccno_1 and gen_extend_insn. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline SVN. Uros. Index: config/i386/i386-expand.c =================================================================== --- config/i386/i386-expand.c (revision 273492) +++ config/i386/i386-expand.c (working copy) @@ -1122,8 +1122,6 @@ ix86_split_idivmod (machine_mode mode, rtx operand rtx_insn *insn; rtx scratch, tmp0, tmp1, tmp2; rtx (*gen_divmod4_1) (rtx, rtx, rtx, rtx); - rtx (*gen_zero_extend) (rtx, rtx); - rtx (*gen_test_ccno_1) (rtx, rtx); switch (mode) { @@ -1135,21 +1133,16 @@ ix86_split_idivmod (machine_mode mode, rtx operand else gen_divmod4_1 = unsigned_p ? gen_udivmodsi4_zext_2 : gen_divmodsi4_zext_2; - gen_zero_extend = gen_zero_extendqisi2; } else - { - gen_divmod4_1 - = unsigned_p ? gen_udivmodsi4_zext_1 : gen_divmodsi4_zext_1; - gen_zero_extend = gen_zero_extendqidi2; - } - gen_test_ccno_1 = gen_testsi_ccno_1; + gen_divmod4_1 + = unsigned_p ? gen_udivmodsi4_zext_1 : gen_divmodsi4_zext_1; break; + case E_DImode: gen_divmod4_1 = unsigned_p ? gen_udivmoddi4_1 : gen_divmoddi4_1; - gen_test_ccno_1 = gen_testdi_ccno_1; - gen_zero_extend = gen_zero_extendqidi2; break; + default: gcc_unreachable (); } @@ -1164,7 +1157,7 @@ ix86_split_idivmod (machine_mode mode, rtx operand emit_move_insn (scratch, operands[2]); scratch = expand_simple_binop (mode, IOR, scratch, operands[3], scratch, 1, OPTAB_DIRECT); - emit_insn (gen_test_ccno_1 (scratch, GEN_INT (-0x100))); + emit_insn (gen_test_ccno_1 (mode, scratch, GEN_INT (-0x100))); tmp0 = gen_rtx_REG (CCNOmode, FLAGS_REG); tmp0 = gen_rtx_EQ (VOIDmode, tmp0, const0_rtx); tmp0 = gen_rtx_IF_THEN_ELSE (VOIDmode, tmp0, @@ -1227,7 +1220,9 @@ ix86_split_idivmod (machine_mode mode, rtx operand /* Zero extend quotient from AL. */ tmp1 = gen_lowpart (QImode, tmp0); - insn = emit_insn (gen_zero_extend (operands[0], tmp1)); + insn = emit_insn (gen_extend_insn + (operands[0], tmp1, + GET_MODE (operands[0]), QImode, 1)); set_unique_reg_note (insn, REG_EQUAL, div); emit_label (end_label); Index: config/i386/i386.md =================================================================== --- config/i386/i386.md (revision 273492) +++ config/i386/i386.md (working copy) @@ -8124,7 +8124,7 @@ ;; On Pentium, "test imm, reg" is pairable only with eax, ax, and al. ;; Note that this excludes ah. -(define_expand "test_ccno_1" +(define_expand "@test_ccno_1" [(set (reg:CCNO FLAGS_REG) (compare:CCNO (and:SWI48 @@ -8142,19 +8142,15 @@ [(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_nonmemory_operand" "Z,Z,e,e,re")) + (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)" "@ test{l}\t{%k1, %k0|%k0, %k1} - test{l}\t{%k1, %k0|%k0, %k1} - test{q}\t{%1, %0|%0, %1} - test{q}\t{%1, %0|%0, %1} test{q}\t{%1, %0|%0, %1}" [(set_attr "type" "test") - (set_attr "modrm" "0,1,0,1,1") - (set_attr "mode" "SI,SI,DI,DI,DI")]) + (set_attr "mode" "SI,DI")]) (define_insn "*testqi_1_maybe_si" [(set (reg FLAGS_REG) @@ -8177,7 +8173,6 @@ return "test{b}\t{%1, %0|%0, %1}"; } [(set_attr "type" "test") - (set_attr "modrm" "0,1,1,1") (set_attr "mode" "QI,QI,QI,SI") (set_attr "pent_pair" "uv,np,uv,np")]) @@ -8191,7 +8186,6 @@ "ix86_match_ccmode (insn, CCNOmode)" "test{}\t{%1, %0|%0, %1}" [(set_attr "type" "test") - (set_attr "modrm" "0,1,1") (set_attr "mode" "") (set_attr "pent_pair" "uv,np,uv")])