From patchwork Fri Jan 5 08:31:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 83380 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BA45385770C for ; Fri, 5 Jan 2024 08:35:23 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id CB18F3858D32 for ; Fri, 5 Jan 2024 08:32:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB18F3858D32 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 CB18F3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704443538; cv=none; b=YouchGPxJxvOjKEKEKS4P/cnTCa6AW79r0AEtcFHommotbSNuH3ams476Z6Y/wGkIkLLVh0+x7Bn1lf0VKpfdLXZkxuZeabbmgr+MY2pskDF8M4/pw2Mzq4xBDnu9jMNWRrrCRM3GQQT4RvpwRYdJRsysXCqi5XhIcEPLZdrhLk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704443538; c=relaxed/simple; bh=aKtk8eJgNnpHbv99i5U5PRRatmoGjOt03HsBPtMny2U=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=R2VIT+qjXc2UIEFVgJ/rYtJiUxWLNBMLJCCyIPe1fMauywzAu0zKkoF+jG2kpooO7UWXsB5EcuKq9Un/cImRB9JIHN2wf707tf7LOwSzqeSarC/EkkJtUuPyhSJlKmBbeKIVggMkcfPhSuK9LklT3xVJ6p0oPT/O+8t4+4QKFfM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ccbbb5eb77so16126481fa.2 for ; Fri, 05 Jan 2024 00:32:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1704443519; x=1705048319; 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=bdwsKRA/bHdKIbN3e2zAkoPAgAbvveuDo9Gav+etqrc=; b=JUbebl5kBv0GZJzRwBwssCi5t7UfYgt8j9PWdljzr84A/2r5pADNIC0ViYc+/bzJtn aHoUWSTwUtRzrMNhwZ5hTmTFFV41+rTNmH5LNVyum/6XVNvNxqEjy/suJJeFF16FEUqe gL6wACawl6kU5k3n2O7KMFBPCKBEdGy0aaZWT7SZh/g71IpmHuYx1Rp7I0K7ZDTlWdLI ebZOfFsP9W/ZxyuAdfQnSbjVT9mG2hUjWyqAidLEXvWoKRQO8jXuF0M4cN4fm+mZgxKc hEELeyqXRoJffklTvk2XyMuigQpVaCkGTgO2iQyZ2LAoYBfHJ5PNcshltEAXlrhG1auO ZdPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443519; x=1705048319; 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=bdwsKRA/bHdKIbN3e2zAkoPAgAbvveuDo9Gav+etqrc=; b=pnUXdpRzoupDmvvROWtP3SOtDIMQmdDb1KvqjN0Fb5QlP2vGmRKvncNjDach9VL1Yl zIiGzpe4x2XSnzQDeYC7KCXTgR8VJ3VYJlsw08tQ75RYhRDIad5H1rPx50QK7a9A6irm yzVR5rOSYe6bbOOo8J3q0oeY1GWopwU9PQ/praYV+CCOe00MPLQW99ztQUY6aUtNlXcS p1oWZ8VFhyjJLhXATZUYvnw+ga6Ye9+ZiqYyPsepgkDdJ3mAXrF2U0wJmaKvu7BtxVRc QBeZgHnW/kDw7+xkrBkKWv5cLj5224jpS4pmmU9qrxTaeK42tTB1idkf7T8E6UMG5ST/ M1ZA== X-Gm-Message-State: AOJu0YzX7Oy3HQTxao8TTTAj2PabwBSBsRPT2/Wv3b3HYWU7qJQYR1sI pQD6ZSCvhBKBZdST1bejVUxuOgS9Dhj/3zmri1eSb1AYIw== X-Google-Smtp-Source: AGHT+IGoel+0qc9mN1+34DBBCNGvUo4eMgkg0r89/l4y9BiQWvzOb12cSt7MRAZS7fdnWhIGyG8hnA== X-Received: by 2002:a2e:8756:0:b0:2cc:63e4:884c with SMTP id q22-20020a2e8756000000b002cc63e4884cmr927368ljj.50.1704443518941; Fri, 05 Jan 2024 00:31:58 -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 h20-20020a05660224d400b0077a1b6f73b9sm303481ioe.41.2024.01.05.00.31.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Jan 2024 00:31:58 -0800 (PST) Message-ID: Date: Fri, 5 Jan 2024 09:31:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Binutils Cc: "H.J. Lu" From: Jan Beulich Subject: [PATCH] x86: actually implement .noopt Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjG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0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL X-Spam-Status: No, score=-3026.0 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+patchwork=sourceware.org@sourceware.org For quite some time we've had support for -O command line options. With that ignoring at least .noopt isn't really a good idea. Re-purpose the optimize-3 test for testing this directive's effect as well. As to the doc addition - this uses the same text as is there for the {nooptimize} pseudo-prefix, despite me not being convinced of the "size" part being fully accurate there (and hence also here). --- I haven't been able to find any applicable documentation for other (perhaps legacy) assemblers' support of .noopt (and .optim). An option to also handle .optim would be to - restore previously saved settings (if optimization was enabled on the command line), - enable a pre-determined level of optimization if optimization was not enabled on the command line. Thoughts? --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -139,6 +139,7 @@ arch_entry; static void update_code_flag (int, int); static void s_insn (int); +static void s_noopt (int); static void set_code_flag (int); static void set_16bit_gcc_code_flag (int); static void set_intel_syntax (int); @@ -1231,7 +1232,7 @@ const pseudo_typeS md_pseudo_table[] = {"value", cons, 2}, {"slong", signed_cons, 4}, {"insn", s_insn, 0}, - {"noopt", s_ignore, 0}, + {"noopt", s_noopt, 0}, {"optim", s_ignore, 0}, {"code16gcc", set_16bit_gcc_code_flag, CODE_16BIT}, {"code16", set_code_flag, CODE_16BIT}, @@ -4966,6 +4967,13 @@ optimize_encoding (void) } } +static void +s_noopt (int dummy ATTRIBUTE_UNUSED) +{ + optimize = 0; + optimize_for_space = 0; +} + /* Return non-zero for load instruction. */ static int --- a/gas/doc/c-i386.texi +++ b/gas/doc/c-i386.texi @@ -763,6 +763,10 @@ be suffixed by @code{@{:d@var{n}@}} to s This can be combined with an embedded broadcast specifier: @samp{8(%eax)@{1to8:d8@}}. +@cindex @code{noopt} directive +@item .noopt +Disable instruction size optimization. + @c FIXME: Document other x86 specific directives ? Eg: .code16gcc, @end table --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -614,6 +614,7 @@ if [gas_32_check] then { run_list_test "optimize-6a" "-I${srcdir}/$subdir -march=+noavx -al" run_dump_test "optimize-6b" run_list_test "optimize-7" "-I${srcdir}/$subdir -march=+noavx2 -al" + run_dump_test "noopt" run_dump_test "lea-optimize" run_dump_test "lea16-optimize" run_dump_test "lea16-optimize2" --- /dev/null +++ b/gas/testsuite/gas/i386/noopt.d @@ -0,0 +1,4 @@ +#as: -Os -I${srcdir}/$subdir +#objdump: -drw +#name: .noopt directive +#dump: optimize-3.d --- /dev/null +++ b/gas/testsuite/gas/i386/noopt.s @@ -0,0 +1,2 @@ + .noopt + .include "optimize-3.s" --- a/gas/testsuite/gas/i386/optimize-3.d +++ b/gas/testsuite/gas/i386/optimize-3.d @@ -1,4 +1,4 @@ -#as: -Os +#as: -Os --defsym USE_PREFIX=1 #objdump: -drw #name: optimized encoding 3 with -Os --- a/gas/testsuite/gas/i386/optimize-3.s +++ b/gas/testsuite/gas/i386/optimize-3.s @@ -1,24 +1,32 @@ # Check instructions with optimized encoding + .macro noopt insn:vararg + .ifdef USE_PREFIX + {nooptimize} \insn + .else + \insn + .endif + .endm + .text _start: - {nooptimize} testl $0x7f, %eax + noopt testl $0x7f, %eax - {nooptimize} lock xchg %ecx, (%edx) - {nooptimize} lock xchg (%ecx), %edx + noopt lock xchg %ecx, (%edx) + noopt lock xchg (%ecx), %edx - {nooptimize} vmovdqa32 %ymm1, %ymm2 - {nooptimize} vmovdqa64 %ymm1, %ymm2 - {nooptimize} vmovdqu8 %xmm1, %xmm2 - {nooptimize} vmovdqu16 %xmm1, %xmm2 - {nooptimize} vmovdqu32 %xmm1, %xmm2 - {nooptimize} vmovdqu64 %xmm1, %xmm2 + noopt vmovdqa32 %ymm1, %ymm2 + noopt vmovdqa64 %ymm1, %ymm2 + noopt vmovdqu8 %xmm1, %xmm2 + noopt vmovdqu16 %xmm1, %xmm2 + noopt vmovdqu32 %xmm1, %xmm2 + noopt vmovdqu64 %xmm1, %xmm2 - {nooptimize} vpandd %xmm2, %xmm3, %xmm4 - {nooptimize} vpandq %ymm2, %ymm3, %ymm4 - {nooptimize} vpandnd %ymm2, %ymm3, %ymm4 - {nooptimize} vpandnq %xmm2, %xmm3, %xmm4 - {nooptimize} vpord %xmm2, %xmm3, %xmm4 - {nooptimize} vporq %ymm2, %ymm3, %ymm4 - {nooptimize} vpxord %ymm2, %ymm3, %ymm4 - {nooptimize} vpxorq %xmm2, %xmm3, %xmm4 + noopt vpandd %xmm2, %xmm3, %xmm4 + noopt vpandq %ymm2, %ymm3, %ymm4 + noopt vpandnd %ymm2, %ymm3, %ymm4 + noopt vpandnq %xmm2, %xmm3, %xmm4 + noopt vpord %xmm2, %xmm3, %xmm4 + noopt vporq %ymm2, %ymm3, %ymm4 + noopt vpxord %ymm2, %ymm3, %ymm4 + noopt vpxorq %xmm2, %xmm3, %xmm4