From patchwork Fri Jan 12 12:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 187714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp121020dyc; Fri, 12 Jan 2024 04:00:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+ZKHgepnwlCTl5UoYv/L6bqFr14byPBMwKEtlH7Rm7bFInQLpNdUeCMijwQHJ3VD0zkEK X-Received: by 2002:a05:620a:3902:b0:783:35ae:18d7 with SMTP id qr2-20020a05620a390200b0078335ae18d7mr2421572qkn.10.1705060821115; Fri, 12 Jan 2024 04:00:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705060821; cv=pass; d=google.com; s=arc-20160816; b=rsNZaMIW0lvppyeaURmpyBb/XlJTtxosp4olf/SSFHS7DsAGuEoMQyxPVUR8+aPw91 OxoFyemjwfSy56OP5OZuw24WyvdA6kDt2Cek7ZG7pnw1wTF98pDo3el85DhpNZaqVFIh 2aNEKs560QlpPA08nWCZXi1YUWy0hb1RWIKTEeawnFzHtBc1nGKQWvxn+pilXSjPbqHs Kuzdj9uh3ZcqIpLSgGMXO5Dv0HPF4wduTAID33yb+XaErjuIu46UjrvrfbuD0/lA7Z59 MlexcEFQiyg3lK9v+7WVIWQbXyun8TBE4+kxIzxkzHksAvFE3NvSN9hZCseTxKh48GRT TA9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :autocrypt:subject:from:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature:arc-filter:dmarc-filter :delivered-to; bh=C7IngvEgJGsyKxjW8HkPK2OwIb4nm2a+3KDXsV2ZYPY=; fh=Plzit+QOfT4w9lMb6sCEH7MLCHiIRZ4B4v+R+r5+YtY=; b=N8b1StbIMk7OYAjHEJdp+Dt9igaQfTn56ySJwwPYIJopkZ1+kg3/i+I7itduhBGw1s a65i4IInyy2S89LV6ptiJTYHN+vzN8n4JkH4dKVxi1ddxQoCcB9sjwoLLNE55znM759a ErqPNpWwq22qRYRPDiq6OamAQ1oIk0aKELU4bOgLC0jElHbFWTxFITyVHhaRB/cJKC5s M6h/TM72uUx0Qt5muzQZ9PergcnFdR6k0LeCqc8NUxYA3e5QU2A+Ho+dOTVdRO86zK+L Ft+gWDXxuwlE6dJanqbjIU1n03A6Qb4TWLaB+zad3ipqY0iJvD1l2qxV9F7BLXSDUXwg 5C8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=JThTQlak; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id o2-20020ae9f502000000b00781c33a3605si2725649qkg.110.2024.01.12.04.00.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 04:00:21 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=JThTQlak; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0266B385802E for ; Fri, 12 Jan 2024 12:00:17 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 5C9DC3858D1E for ; Fri, 12 Jan 2024 12:00:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9DC3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C9DC3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705060809; cv=none; b=BQIcx3ziVjO8MZHk9/MQnPq/kJDOZEc1aBc1Bn26zHCFc3CH4EfXEPoX19NA1s5pmtsVsJK7okbBeNkv8y9dK6FaTmMv64CB39u+rqN2wQDiRF7xc4V8ZRS3YTliyKrptkQMXP794WLso1zvxq5kE7MK1OXUHf/iI1mz879DoCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705060809; c=relaxed/simple; bh=WwFwglOI3YRIBBuaL1nYNU45M2ZqhrdNIFS0JU8v9Tc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=m8z6FV3g0Mj7Y+yoFIUi1rmlSQ2yZMO43vIzzfzxeFBmWsevjfNyRRJ++ixcMjMRZllF1EOymuymi6xDaoZnZ2a77g/Q5yCs3D0P5/jOZ2GCgjIZph8R6CivZTiI/G7vLoAtG5kJ+Va5WSjCnGtq5qLoCAt3XzsAZMWCSEQxPnw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50e67e37661so8537549e87.0 for ; Fri, 12 Jan 2024 04:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1705060803; x=1705665603; darn=sourceware.org; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=C7IngvEgJGsyKxjW8HkPK2OwIb4nm2a+3KDXsV2ZYPY=; b=JThTQlakH2XvYZZ50afRXRKxgzdXMoqNvcZBeT0hAwxhBYh4+Hx7PIZV1F2MFO/oHl sJQDi0d/Mxuv1SIwOiUpD8pyElbbk1txzaRR+NKzK0mlagJ1iMS7G8uaa/0QpP7LtbM+ j/12mXGQbK68HNJpZsIKgiFLh+OtPwyrgTodc+KuK9oKHc6GnjjrLAYSkWF7rGjCoO4m D7SPpFD1eJ19Nhofn5ClSs2WNwxkc6Mu1Xb/0XbShPemdfIb9j5CFxWr12q6iqBNhbyT 2UXbRYt2+qpcEGSpiyH86hZT9DgtDhmwzu2L23p9FBDVIWLDGMKnGSEG90dLs2vrwFRv kFMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705060803; x=1705665603; h=content-transfer-encoding:autocrypt:subject:from:cc:to :content-language:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=C7IngvEgJGsyKxjW8HkPK2OwIb4nm2a+3KDXsV2ZYPY=; b=GszGiFmAPmHoB8LycQJDa4X4Fw5zaC2YLOscpwHH4DL73xler74fX/JDmuBT2TaAvO cLj8BvsCLHlnaMX4uUTksejVlrURL62KucEprkMyW3u/Ky0yY+yBF6lAD9LvWnTrnpRP HCI1GxOYoyCtPRcJQpZdSUA9bN2TVpDdWMI8KaeegImqf2g9tOWqdE+0KiVU+wgpWtlP 80BrRoQw0C8Mx9URbpcAGVraNF5TIydirP8O6b992pNpF5dHM8lprsSAx8nZXiyP1AtW ZOTMnr6tz7O1+dn8uYVQ+hHWx7L+DbyVIEa8DpYGyEbYEB/tagrq5rjwPSRuPX/KALs1 MXMA== X-Gm-Message-State: AOJu0YxF9W2pwciQKk04UVUpI7vM8hw1OwuqnhzvjNgWYueRhCx/spqi RSz85ID++HMUJLsabeLMtqg5MbqDuYahy+BVWzSea1QOTA== X-Received: by 2002:a05:6512:398f:b0:50e:7479:79da with SMTP id j15-20020a056512398f00b0050e747979damr831716lfu.24.1705060803638; Fri, 12 Jan 2024 04:00:03 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id j2-20020a6b3102000000b007bf197d6ca8sm531569ioa.25.2024.01.12.04.00.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Jan 2024 04:00:03 -0800 (PST) Message-ID: Date: Fri, 12 Jan 2024 13:00:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Binutils Cc: "H.J. Lu" , "Hu, Lin1" From: Jan Beulich Subject: [PATCH] x86/APX: optimize MOVBE Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRW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FKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL X-Spam-Status: No, score=-3025.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787885855786390919 X-GMAIL-MSGID: 1787885855786390919 With identical source and destination it can be covered by the NDD-to- legacy conversion logic as well, even if in this case the original insn doesn't use an NDD encoding. The size savings are even better here, for the replacement (BSWAP) not having a ModR/M byte. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -7872,7 +7872,8 @@ match_template (char mnem_suffix) && t + 1 < current_templates.end && !t[1].opcode_modifier.evex && t[1].opcode_space <= SPACE_0F38 - && t->opcode_modifier.vexvvvv == VexVVVV_DST + && (t->opcode_modifier.vexvvvv == VexVVVV_DST + || t->mnem_off == MN_movbe) && (i.types[i.operands - 1].bitfield.dword || i.types[i.operands - 1].bitfield.qword)) { --- a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d +++ b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.d @@ -118,6 +118,9 @@ Disassembly of section .text: \s*[a-f0-9]+:\s*67 0f 4d 90 90 90 90 90 cmovge -0x6f6f6f70\(%eax\),%edx \s*[a-f0-9]+:\s*67 0f 4e 90 90 90 90 90 cmovle -0x6f6f6f70\(%eax\),%edx \s*[a-f0-9]+:\s*67 0f 4f 90 90 90 90 90 cmovg -0x6f6f6f70\(%eax\),%edx +\s*[a-f0-9]+:\s*62 f4 7d 08 60 c0 movbe %ax,%ax +\s*[a-f0-9]+:\s*49 0f c8 bswap %r8 +\s*[a-f0-9]+:\s*d5 98 c8 bswap %r16 \s*[a-f0-9]+:\s*66 0f 38 f6 c3 adcx %ebx,%eax \s*[a-f0-9]+:\s*66 0f 38 f6 c3 adcx %ebx,%eax \s*[a-f0-9]+:\s*62 f4 fd 18 66 c3 adcx %rbx,%rax,%rax --- a/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s +++ b/gas/testsuite/gas/i386/x86-64-apx-ndd-optimize.s @@ -111,6 +111,9 @@ cmovl 0x90909090(%eax),%edx,%edx cmovge 0x90909090(%eax),%edx,%edx cmovle 0x90909090(%eax),%edx,%edx cmovg 0x90909090(%eax),%edx,%edx +movbe %ax,%ax +movbe %r8,%r8 +movbe %r16,%r16 adcx %ebx,%eax,%eax adcx %eax,%ebx,%eax adcx %rbx,%rax,%rax --- a/opcodes/i386-opc.tbl +++ b/opcodes/i386-opc.tbl @@ -210,6 +210,9 @@ mov, 0xf24, i386&No64, D|RegMem|IgnoreSi // Move after swapping the bytes movbe, 0x0f38f0, Movbe, D|Modrm|CheckOperandSize|No_bSuf|No_sSuf, { Word|Dword|Qword|Unspecified|BaseIndex, Reg16|Reg32|Reg64 } movbe, 0x60, Movbe&APX_F, D|Modrm|CheckOperandSize|No_bSuf|No_sSuf|EVexMap4, { Reg16|Reg32|Reg64|Unspecified|BaseIndex, Reg16|Reg32|Reg64 } +// This really is BSWAP, but wants "duplicating" here for easy EVEX -> REX2 +// conversion, restarting with the next sequential template. +movbe, 0xfc8, Movbe&APX_F, No_bSuf|No_wSuf|No_sSuf, { Reg32|Reg64 } // Move with sign extend. movsb, 0xfbe, i386, Modrm|No_bSuf|No_sSuf, { Reg8|Unspecified|BaseIndex, Reg16|Reg32|Reg64 }