public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Cc: "H.J. Lu" <hjl.tools@gmail.com>
Subject: [PATCH 2/3] x86-64: respect {nooptimize} when building VEX prefix
Date: Fri, 27 Jan 2023 12:35:33 +0100	[thread overview]
Message-ID: <fd4ad7a1-565d-12ea-c7e0-744d35d77aa6@suse.com> (raw)
In-Reply-To: <bea7bb2c-0fa1-6bc3-fb5c-223facaf47a2@suse.com>

Swapping operands for commutative insns occurs outside of
optimize_encoding() and hence needs explicit checking for a request to
avoid any optimizations.

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -3624,7 +3624,8 @@ build_vex_prefix (const insn_template *t
       && i.reg_operands == i.operands - i.imm_operands
       && i.tm.opcode_modifier.vex
       && i.tm.opcode_modifier.commutative
-      && (i.tm.opcode_modifier.sse2avx || optimize > 1)
+      && (i.tm.opcode_modifier.sse2avx
+	  || (optimize > 1 && !i.no_optimize))
       && i.rex == REX_B
       && i.vex.register_specifier
       && !(i.vex.register_specifier->reg_flags & RegRex))
--- a/gas/testsuite/gas/i386/x86-64-optimize-4.d
+++ b/gas/testsuite/gas/i386/x86-64-optimize-4.d
@@ -9,6 +9,8 @@ Disassembly of section .text:
 
 0+ <_start>:
  +[a-f0-9]+:	a9 7f 00 00 00       	test   \$0x7f,%eax
+ +[a-f0-9]+:	c4 c1 61 db e4       	vpand  %xmm12,%xmm3,%xmm4
+ +[a-f0-9]+:	c5 91 db e2          	vpand  %xmm2,%xmm13,%xmm4
  +[a-f0-9]+:	62 f1 7d 28 6f d1    	vmovdqa32 %ymm1,%ymm2
  +[a-f0-9]+:	62 f1 fd 28 6f d1    	vmovdqa64 %ymm1,%ymm2
  +[a-f0-9]+:	62 f1 7f 08 6f d1    	vmovdqu8 %xmm1,%xmm2
--- a/gas/testsuite/gas/i386/x86-64-optimize-4.s
+++ b/gas/testsuite/gas/i386/x86-64-optimize-4.s
@@ -5,6 +5,9 @@
 _start:
 	{nooptimize} testl $0x7f, %eax
 
+	{nooptimize} vpand	%xmm12, %xmm3, %xmm4
+	{nooptimize} vpand	%xmm2, %xmm13, %xmm4
+
 	{nooptimize} vmovdqa32	%ymm1, %ymm2
 	{nooptimize} vmovdqa64	%ymm1, %ymm2
 	{nooptimize} vmovdqu8	%xmm1, %xmm2


  parent reply	other threads:[~2023-01-27 11:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27 11:34 [PATCH 0/3] x86: small adjustments to optimization logic Jan Beulich
2023-01-27 11:35 ` [PATCH 1/3] x86: respect {nooptimize} for LEA Jan Beulich
2023-01-27 11:35 ` Jan Beulich [this message]
2023-01-27 11:36 ` [PATCH 3/3] x86: drop LOCK from XCHG when optimizing Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fd4ad7a1-565d-12ea-c7e0-744d35d77aa6@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).