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) */