From patchwork Sat Sep 3 15:05:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 37629 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp1617269pzh; Sat, 3 Sep 2022 08:05:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR5bZL9yQkH/XHVKg0UjXwo4s3yo74iVy/K9zUK+3Fd91gr+lV0e46Kw3TtQ0vye3rbc8gW6 X-Received: by 2002:aa7:d7c1:0:b0:447:d3ec:69cb with SMTP id e1-20020aa7d7c1000000b00447d3ec69cbmr34041177eds.105.1662217551990; Sat, 03 Sep 2022 08:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662217551; cv=none; d=google.com; s=arc-20160816; b=Cn14IE04Hxxo/aeKlpAWhch+JhwQ6iwYBapON7jY3DJRsU3AYVvtgA5jb9Ld+8I8Jx 6nJgrH8XGwMiAkfa77obppmqdy4OF/57OwsIh6QI75/yjnnePULvF2rolxinh78Lta7q iSiXT2AXIJ/GAWaycvCeK3BXXl1peQnREgssXlge875ihSdfKB2BWrmc5VY8SgdDB2Ra nIy8BsozW+4X2YBLGSGVSywQgR6ReQZ1DrvztwzBUc9QMBhiwly/S+ac+ALk3twkDd7O RUZuggQwcHF5VVW88xYWYlkMLPCCkhJm5RCvdBjZxr4EkQ7Qn3SgxQYEGo9xu0AgKmzl hx4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=V06J3rBVXU0eEkUFcAj3m8DA2tUHGQgvvY3ckSYBDyA=; b=Usa81MVlFDi5UUV3cW2lNs+RbGX0WacIXMYSgb6rLLxbP0zrigQO5qv4cd9ds9jGxy USLrJCgpgDTwFRhvf5Fl53n4k1lpVvZkSEp2emV31apu71I2CzEixSj7hRpY9dkoOhff g92Bgut6MMrDsFkUIkWOGIaJVF7h6EsebPPn+D166gifjrB2T2dqmULM/JMiXH3Lyz5k TtXXM+xAGQBdAs7+TUY/yxzBwDctrTdDZsPJYFnB83N9BtGpH7ryXcceD+i0gaG8m6ub 2qxUZdOqD22Km1ftP3vSun4wqmnFFGjwjw0obstDOqX9KCUyrhFBU1yF0S1+FCwPM2dU svwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l4-20020a056402344400b004464fef9fc8si3310567edc.57.2022.09.03.08.05.38; Sat, 03 Sep 2022 08:05:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE7F868B9C3; Sat, 3 Sep 2022 18:05:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E3AC68B922 for ; Sat, 3 Sep 2022 18:05:19 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 71996C0003 for ; Sat, 3 Sep 2022 18:05:18 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Sep 2022 18:05:17 +0300 Message-Id: <20220903150518.169643-1-remi@remlab.net> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] aarch64: relax byte-swap assembler constraints X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ku6bC+/tFwFN From: Rémi Denis-Courmont There are no particular reasons to force the compiler to use the same register as output and input operand. This forces an extra MOV instruction if the input value needs to be reused after the swap. In most cases, this makes no differences, as the compiler will seleect the same register for both operands either way. --- libavutil/aarch64/bswap.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libavutil/aarch64/bswap.h b/libavutil/aarch64/bswap.h index 1e735c52cf..7abca657ba 100644 --- a/libavutil/aarch64/bswap.h +++ b/libavutil/aarch64/bswap.h @@ -28,22 +28,28 @@ #define av_bswap16 av_bswap16 static av_always_inline av_const unsigned av_bswap16(unsigned x) { - __asm__("rev16 %w0, %w0" : "+r"(x)); - return x; + unsigned y; + + __asm__("rev16 %w0, %w1" : "=r"(y) : "r"(x)); + return y; } #define av_bswap32 av_bswap32 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { - __asm__("rev %w0, %w0" : "+r"(x)); - return x; + uint32_t y; + + __asm__("rev %w0, %w1" : "=r"(y) : "r"(x)); + return y; } #define av_bswap64 av_bswap64 static av_always_inline av_const uint64_t av_bswap64(uint64_t x) { - __asm__("rev %0, %0" : "+r"(x)); - return x; + uint64_t y; + + __asm__("rev %0, %1" : "=r"(y) : "r"(x)); + return y; } #endif /* HAVE_INLINE_ASM */ From patchwork Sat Sep 3 15:05:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 37628 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp1617076pzh; Sat, 3 Sep 2022 08:05:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Q5E0i3kI+cIiUzHM5vHxHU3QN/B+5cjid5qsV4mFj6AOrlU895xWtfKEDK90K/5CdIeXQ X-Received: by 2002:a05:6402:241d:b0:443:39c5:808b with SMTP id t29-20020a056402241d00b0044339c5808bmr37531751eda.39.1662217531751; Sat, 03 Sep 2022 08:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662217531; cv=none; d=google.com; s=arc-20160816; b=fqr45gwmNHz6+xVnZymePEQq+7NG11CieST7e+vNyNF6Orju+CUXh8Cr7iB0C3BcYq D+ZQAj6lFuCRfh4hXQM5QLeJX2MJtkYM0rosLSrKnIGTtROnzjMpCTHB4b+/XIUeNYBa jAygU/Q3GDYYs4ZQ+MuOahTL8jvXQ4XJaIE6M7lGxlI9pyEJIx8sGIuJkj8rRWFlH8pN EoKjhHP6nEhy9qFce4WzqHmD06m288ld+PPA6iY3N0wnCvz5tOwthqCQkT362cXYSdHl h148W9uyxZ61DfLoKJ+liRPg0oHnMhOnDjXdADPiwCH/ItNIKr+lerkKSsVZmgPHlnK2 bCfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=5YSaLYkgsjTBipy3sPIm8IMYrMWTfjtGuuHOKKv3G1g=; b=JsarAg76OoUIrDcy6ulf7mEbskrMtkG7peKE896nyMTxQEqOkAsL4X2fbw1rHp9sM9 FmHRDw0exx0wuOstx1+VuzTaTKQBLmuGb7CteanFlyFt21ePJKhDdf5SDk/gNZkvZMY5 wZy0PFS7E3LyortPwtVQXveUMhIbjFdxt+FFHx4J6Dyb+HM20rQ3dJkNKwToLdiqS+Kt 2PEI9ZcoF4DqPfrHL41qaFZBLzlUn/599xisRzEMvfrbasb5dajVS9eibMae9RJaXLuA ICEz2OMox+8VUkxZuimENOQd+Srx4ZDNzNWStfTdPLJNNg7uatY526EWWChavTKTZQXH Fg2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dr14-20020a170907720e00b0073d5ae171fdsi3062182ejc.549.2022.09.03.08.05.29; Sat, 03 Sep 2022 08:05:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D345F68B98F; Sat, 3 Sep 2022 18:05:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 034C868B7B3 for ; Sat, 3 Sep 2022 18:05:18 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id A4B73C0029 for ; Sat, 3 Sep 2022 18:05:18 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Sep 2022 18:05:18 +0300 Message-Id: <20220903150518.169643-2-remi@remlab.net> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] arm: relax byte-swap assembler constraints X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: nXe9gpXs53Ey From: Rémi Denis-Courmont There are no particular reasons to force the compiler to use the same register as output and input operand. This forces an extra MOV instruction if the input value needs to be reused after the swap. In most cases, this makes no differences, as the compiler will seleect the same register for both operands either way. --- libavutil/arm/bswap.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavutil/arm/bswap.h b/libavutil/arm/bswap.h index 611ff0ad5b..c3460e035d 100644 --- a/libavutil/arm/bswap.h +++ b/libavutil/arm/bswap.h @@ -39,8 +39,10 @@ static av_always_inline av_const uint32_t av_bswap32(uint32_t x) #define av_bswap16 av_bswap16 static av_always_inline av_const unsigned av_bswap16(unsigned x) { - __asm__("rev16 %0, %0" : "+r"(x)); - return x; + unsigned y; + + __asm__("rev16 %0, %1" : "=r"(y) : "r"(x)); + return y; } #endif @@ -48,17 +50,18 @@ static av_always_inline av_const unsigned av_bswap16(unsigned x) #define av_bswap32 av_bswap32 static av_always_inline av_const uint32_t av_bswap32(uint32_t x) { + uint32_t y; #if HAVE_ARMV6_INLINE - __asm__("rev %0, %0" : "+r"(x)); + __asm__("rev %0, %1" : "=r"(y) : "r"(x)); #else uint32_t t; - __asm__ ("eor %1, %0, %0, ror #16 \n\t" + __asm__ ("eor %1, %2, %2, ror #16 \n\t" "bic %1, %1, #0xFF0000 \n\t" - "mov %0, %0, ror #8 \n\t" + "mov %0, %2, ror #8 \n\t" "eor %0, %0, %1, lsr #8 \n\t" - : "+r"(x), "=&r"(t)); + : "=r"(y), "=&r"(t) : "r"(x)); #endif /* HAVE_ARMV6_INLINE */ - return x; + return y; } #endif /* AV_GCC_VERSION_AT_MOST(4,4) */