From patchwork Mon Nov 6 17:30:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 162095 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2814426vqu; Mon, 6 Nov 2023 09:30:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFsU/MAvSNsG+bK4gIg5eENA2fSOM37DNAyFz2T7qmKiZ564r/foTwLHxcnO3iFcgtdbd+U X-Received: by 2002:ac8:4e49:0:b0:41e:9953:f273 with SMTP id e9-20020ac84e49000000b0041e9953f273mr13793270qtw.45.1699291839001; Mon, 06 Nov 2023 09:30:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699291838; cv=pass; d=google.com; s=arc-20160816; b=KHIRe1vPY73WzJ4MZJh6sET1hFc48/R7fAtl5PkLQM56R3/+da91ZblyiZg4UId9Pk FAE+V9zp2xU88ISootTMzMw3EctjfJnYGD6425P0zaj0PvAvY3KlKFov59MoRlui1CvL 7xawXLOXaEQ0A4YqTyraeJcu3qglUoQBhd5CTV4iP58TyihxCt+YEUeCaoagXFDHpaDi YPFz5LhCw1MchchTLEic3itA5NyNvDMQltvbL+EoEZsvwnk1Cl5wX1q3O3YrPGnJ1+tk pf+aAlcoLuCy2S9IZ/RSdx9ZB4CKatZj5pTtsJm/h7SLa/LVuaz4Uy0dGkd7JDd4PsRw 7Zpw== 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-language:thread-index :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=4o5qUaoSIzwm2xWcL6sGCYvf8Se9UCaGxfkjEzTo72o=; fh=Ht8bq8SVyF6sx4+E7Os+tBO2MuNVfxRGp/jyiuwYCzE=; b=AhYU0uIowe73Cz9Mc21cnwTvqGI77WSpCv8l+TRR+NrOMvGIsWNStduGbqfM0bu2Wi AzqYPEGl0dMXEhnTCvylmcmKwtA+KSe9ZWrESHV9csyVYQPXc/WMCl/id6TCq+Livz3f EMgxH7fivweABHRJqAYTyMqZVe7ihkTQoCSXvE6iWRvuHfKomJ68xPWshL+34N0CNLNG Kf2OmcK1x/YnGlVUVMMZFJtjLJnw6Qc70Ya2HkFUmDTMeI+232n45w2HaYPLASNpFfRp arbHKXCcy2GJheZhD1EhiJxSkMQs4HoZv1CRVOBJOYi8uKCBlQX2PK01QKr1mCkM8joI e0Xg== ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=nuA8o4VQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j6-20020ac85c46000000b004196dab68a4si6081839qtj.656.2023.11.06.09.30.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 09:30:38 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=fail header.i=@nextmovesoftware.com header.s=default header.b=nuA8o4VQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AAF083857036 for ; Mon, 6 Nov 2023 17:30:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 4CF543858D20 for ; Mon, 6 Nov 2023 17:30:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CF543858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4CF543858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=162.254.253.69 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699291813; cv=none; b=NyUaUMyhEvhHpxlpY4sqkULIMpqS2sGOnVhUJYpbFCwSe8DR8WueOe4bsyx8qzrGEM4BMtiH/Q3mFXo5engIVafjnZFrqw16p/BdtTB8ddbp0Agw2feWLGUL33eRHWcY2KKLDLZClmt9kOiPodDZCEpI/tsLnXnKtpxH9fPt71U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699291813; c=relaxed/simple; bh=+OOpkYDtaWrrb8wx60UhbtYKmgwo69Y0Hku/q1G2HxU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jMYoWbTWTpYz7uRNdyGUMFiPj0sNKRoU6+a4iGjmxVkFg8+PS7NxbtazFst9sKorrXR80xm5YBtbIBo3V2SXibgR4H6Dp0PyQ8M8qPem3ZE0jumwaxoA297re7tAsUmGMeYOvS1r5LivR4H1y26gtkoVTBLCsGlueI/G/P7nVJw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4o5qUaoSIzwm2xWcL6sGCYvf8Se9UCaGxfkjEzTo72o=; b=nuA8o4VQtLYlRpKJVtjO22c/PQ OQht0BqEq5Ut9qCub/faOnvSsMYieKzzO1t6ni7PCHo9mGimCjDJdKAw7DONefGO7Tf3HwLCUauH9 kRPzNCaVnbRn44wC81DoM6GyDDRlV0qKeFEKM5vKqDq45Ipxd4gju8+zq+RlQy97PRTHIHN6dqqL6 1qU/7VQJ4v9pBkugnt77Zo4GJU+Rc4Nd7GrUIaYy/8DttDCNQbeswQi4No9rOwnFezhykdmVFzvKx ZABPUUPOO1RraGp3SQpNaxBeXpl/+QntXWNS71EkBkWJDq0rP82YwH0r+48XS3wdyGKLeM9t4qLMb AyqPtTLg==; Received: from [185.62.158.67] (port=56109 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1r03QQ-0004GV-1A; Mon, 06 Nov 2023 12:30:10 -0500 From: "Roger Sayle" To: Cc: "'Claudiu Zissulescu'" Subject: [ARC PATCH] Improved DImode rotates and right shifts by one bit. Date: Mon, 6 Nov 2023 17:30:06 -0000 Message-ID: <01fd01da10d6$e3c2ef60$ab48ce20$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdoQ1kbkQaagx0c/Q9Kg/JL/RupmRg== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781836639780068137 X-GMAIL-MSGID: 1781836639780068137 This patch improves the code generated for DImode right shifts (both arithmetic and logical) by a single bit, and also for DImode rotates (both left and right) by a single bit. In approach, this is similar to the recently added DImode left shift by a single bit patch, but also builds upon i386.md's UNSPEC carry flag representation: https://gcc.gnu.org/pipermail/gcc-patches/2023-October/632169.html The benefits can be seen from the four new test cases: long long ashr(long long x) { return x >> 1; } Before: ashr: asl r2,r1,31 lsr_s r0,r0 or_s r0,r0,r2 j_s.d [blink] asr_s r1,r1,1 After: ashr: asr.f r1,r1 j_s.d [blink] rrc r0,r0 unsigned long long lshr(unsigned long long x) { return x >> 1; } Before: lshr: asl r2,r1,31 lsr_s r0,r0 or_s r0,r0,r2 j_s.d [blink] lsr_s r1,r1 After: lshr: lsr.f r1,r1 j_s.d [blink] rrc r0,r0 unsigned long long rotl(unsigned long long x) { return (x<<1) | (x>>63); } Before: rotl: lsr r12,r1,31 lsr r2,r0,31 asl_s r3,r0,1 asl_s r1,r1,1 or r0,r12,r3 j_s.d [blink] or_s r1,r1,r2 After: rotl: add.f r0,r0,r0 adc.f r1,r1,r1 j_s.d [blink] add.cs r0,r0,1 unsigned long long rotr(unsigned long long x) { return (x>>1) | (x<<63); } Before: rotr: asl r12,r1,31 asl r2,r0,31 lsr_s r3,r0 lsr_s r1,r1 or r0,r12,r3 j_s.d [blink] or_s r1,r1,r2 After: rotr: asr.f 0,r0 rrc.f r1,r1 j_s.d [blink] rrc r0,r0 On CPUs without a barrel shifter the improvements are even better. Tested with a cross-compiler to arc-linux hosted on x86_64, with no new (compile-only) regressions from make -k check. Ok for mainline if this passes Claudiu's nightly testing? 2023-11-06 Roger Sayle gcc/ChangeLog * config/arc/arc.md (UNSPEC_ARC_CC_NEZ): New UNSPEC that represents the carry flag being set if the operand is non-zero. (adc_f): New define_insn representing adc with updated flags. (ashrdi3): New define_expand that only handles shifts by 1. (ashrdi3_cnt1): New pre-reload define_insn_and_split. (lshrdi3): New define_expand that only handles shifts by 1. (lshrdi3_cnt1): New pre-reload define_insn_and_split. (rrcsi2): New define_insn for rrc (SImode rotate right through carry). (rrcsi2_carry): Likewise for rrc.f, as above but updating flags. (rotldi3): New define_expand that only handles rotates by 1. (rotldi3_cnt1): New pre-reload define_insn_and_split. (rotrdi3): New define_expand that only handles rotates by 1. (rotrdi3_cnt1): New pre-reload define_insn_and_split. (lshrsi3_cnt1_carry): New define_insn for lsr.f. (ashrsi3_cnt1_carry): New define_insn for asr.f. (btst_0_carry): New define_insn for asr.f without result. gcc/testsuite/ChangeLog * gcc.target/arc/ashrdi3-1.c: New test case. * gcc.target/arc/lshrdi3-1.c: Likewise. * gcc.target/arc/rotldi3-1.c: Likewise. * gcc.target/arc/rotrdi3-1.c: Likewise. Thanks in advance, Roger diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index 7702978..97231b9 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -137,6 +137,7 @@ UNSPEC_ARC_VMAC2HU UNSPEC_ARC_VMPY2H UNSPEC_ARC_VMPY2HU + UNSPEC_ARC_CC_NEZ VUNSPEC_ARC_RTIE VUNSPEC_ARC_SYNC @@ -2790,6 +2791,31 @@ archs4x, archs4xd" (set_attr "type" "cc_arith") (set_attr "length" "4,4,4,4,8,8")]) +(define_insn "adc_f" + [(set (reg:CC_C CC_REG) + (compare:CC_C + (zero_extend:DI + (plus:SI + (plus:SI + (ltu:SI (reg:CC_C CC_REG) (const_int 0)) + (match_operand:SI 1 "register_operand" "%r")) + (match_operand:SI 2 "register_operand" "r"))) + (plus:DI + (ltu:DI (reg:CC_C CC_REG) (const_int 0)) + (zero_extend:DI (match_dup 1))))) + (set (match_operand:SI 0 "register_operand" "=r") + (plus:SI + (plus:SI + (ltu:SI (reg:CC_C CC_REG) (const_int 0)) + (match_dup 1)) + (match_dup 2)))] + "" + "adc.f\\t%0,%1,%2" + [(set_attr "cond" "set") + (set_attr "predicable" "no") + (set_attr "type" "cc_arith") + (set_attr "length" "4")]) + ; combiner-splitter cmp / scc -> cmp / adc (define_split [(set (match_operand:SI 0 "dest_reg_operand" "") @@ -3530,6 +3556,68 @@ archs4x, archs4xd" "" [(set_attr "length" "8")]) +(define_expand "ashrdi3" + [(parallel + [(set (match_operand:DI 0 "register_operand") + (ashiftrt:DI (match_operand:DI 1 "register_operand") + (match_operand:QI 2 "const_int_operand"))) + (clobber (reg:CC CC_REG))])] + "" +{ + if (operands[2] != const1_rtx) + FAIL; +}) + +;; Split into asr.f hi; rrc lo +(define_insn_and_split "*ashrdi3_cnt1" + [(set (match_operand:DI 0 "register_operand") + (ashiftrt:DI (match_operand:DI 1 "register_operand") + (const_int 1))) + (clobber (reg:CC CC_REG))] + "arc_pre_reload_split ()" + "#" + "&& 1" + [(const_int 0)] +{ + emit_insn (gen_ashrsi3_cnt1_carry (gen_highpart (SImode, operands[0]), + gen_highpart (SImode, operands[1]))); + emit_insn (gen_rrcsi2 (gen_lowpart (SImode, operands[0]), + gen_lowpart (SImode, operands[1]))); + DONE; +} + [(set_attr "length" "8")]) + +(define_expand "lshrdi3" + [(parallel + [(set (match_operand:DI 0 "register_operand") + (lshiftrt:DI (match_operand:DI 1 "register_operand") + (match_operand:QI 2 "const_int_operand"))) + (clobber (reg:CC CC_REG))])] + "" +{ + if (operands[2] != const1_rtx) + FAIL; +}) + +;; Split into lsr.f hi; rrc lo +(define_insn_and_split "*lshrdi3_cnt1" + [(set (match_operand:DI 0 "register_operand") + (lshiftrt:DI (match_operand:DI 1 "register_operand") + (const_int 1))) + (clobber (reg:CC CC_REG))] + "arc_pre_reload_split ()" + "#" + "&& 1" + [(const_int 0)] +{ + emit_insn (gen_lshrsi3_cnt1_carry (gen_highpart (SImode, operands[0]), + gen_highpart (SImode, operands[1]))); + emit_insn (gen_rrcsi2 (gen_lowpart (SImode, operands[0]), + gen_lowpart (SImode, operands[1]))); + DONE; +} + [(set_attr "length" "8")]) + ;; Rotate instructions. (define_insn "rotrsi3_insn" @@ -3571,6 +3659,103 @@ archs4x, archs4xd" } }) +;; Rotate through carry flag + +(define_insn "rrcsi2" + [(set (match_operand:SI 0 "dest_reg_operand" "=r") + (plus:SI + (lshiftrt:SI (match_operand:SI 1 "register_operand" "r") + (const_int 1)) + (ashift:SI (ltu:SI (reg:CC_C CC_REG) (const_int 0)) + (const_int 31))))] + "" + "rrc\\t%0,%1" + [(set_attr "type" "shift") + (set_attr "predicable" "no") + (set_attr "length" "4")]) + +(define_insn "rrcsi2_carry" + [(set (reg:CC_C CC_REG) + (unspec:CC_C [(and:SI (match_operand:SI 1 "register_operand" "r") + (const_int 1))] UNSPEC_ARC_CC_NEZ)) + (set (match_operand:SI 0 "dest_reg_operand" "=r") + (plus:SI + (lshiftrt:SI (match_dup 1) (const_int 1)) + (ashift:SI (ltu:SI (reg:CC_C CC_REG) (const_int 0)) + (const_int 31))))] + "" + "rrc.f\\t%0,%1" + [(set_attr "type" "shift") + (set_attr "predicable" "no") + (set_attr "length" "4")]) + +;; DImode Rotate instructions + +(define_expand "rotldi3" + [(parallel + [(set (match_operand:DI 0 "register_operand") + (rotate:DI (match_operand:DI 1 "register_operand") + (match_operand:QI 2 "const_int_operand"))) + (clobber (reg:CC CC_REG))])] + "" +{ + if (operands[2] != const1_rtx) + FAIL; +}) + +;; split into add.f lo; adc.f hi; adc lo +(define_insn_and_split "*rotldi3_cnt1" + [(set (match_operand:DI 0 "register_operand") + (rotate:DI (match_operand:DI 1 "register_operand") + (const_int 1))) + (clobber (reg:CC CC_REG))] + "arc_pre_reload_split ()" + "#" + "&& 1" + [(const_int 0)] +{ + rtx lo0 = gen_lowpart (SImode, operands[0]); + rtx lo1 = gen_lowpart (SImode, operands[1]); + rtx hi1 = gen_highpart (SImode, operands[1]); + emit_insn (gen_add_f (lo0, lo1, lo1)); + emit_insn (gen_adc_f (gen_highpart (SImode, operands[0]), hi1, hi1)); + emit_insn (gen_adc (lo0, lo0, const0_rtx)); + DONE; +} + [(set_attr "length" "12")]) + +(define_expand "rotrdi3" + [(parallel + [(set (match_operand:DI 0 "register_operand") + (rotatert:DI (match_operand:DI 1 "register_operand") + (match_operand:QI 2 "const_int_operand"))) + (clobber (reg:CC CC_REG))])] + "" +{ + if (operands[2] != const1_rtx) + FAIL; +}) + +;; split into asr.f lo; rrc.f hi; rrc lo +(define_insn_and_split "*rotrdi3_cnt1" + [(set (match_operand:DI 0 "register_operand") + (rotatert:DI (match_operand:DI 1 "register_operand") + (const_int 1))) + (clobber (reg:CC CC_REG))] + "arc_pre_reload_split ()" + "#" + "&& 1" + [(const_int 0)] +{ + rtx lo = gen_lowpart (SImode, operands[1]); + emit_insn (gen_btst_0_carry (lo)); + emit_insn (gen_rrcsi2_carry (gen_highpart (SImode, operands[0]), + gen_highpart (SImode, operands[1]))); + emit_insn (gen_rrcsi2 (gen_lowpart (SImode, operands[0]), lo)); + DONE; +} + [(set_attr "length" "12")]) + ;; Compare / branch instructions. (define_expand "cbranchsi4" @@ -6022,6 +6207,18 @@ archs4x, archs4xd" (set_attr "iscompact" "maybe,false") (set_attr "predicable" "no,no")]) +(define_insn "lshrsi3_cnt1_carry" + [(set (reg:CC_C CC_REG) + (unspec:CC_C [(and:SI (match_operand:SI 1 "register_operand" "r") + (const_int 1))] UNSPEC_ARC_CC_NEZ)) + (set (match_operand:SI 0 "dest_reg_operand" "=r") + (lshiftrt:SI (match_dup 1) (const_int 1)))] + "" + "lsr.f\\t%0,%1" + [(set_attr "type" "unary") + (set_attr "length" "4") + (set_attr "predicable" "no")]) + (define_insn "ashrsi3_cnt1" [(set (match_operand:SI 0 "dest_reg_operand" "=q,w") (ashiftrt:SI (match_operand:SI 1 "register_operand" "q,c") @@ -6032,6 +6229,28 @@ archs4x, archs4xd" (set_attr "iscompact" "maybe,false") (set_attr "predicable" "no,no")]) +(define_insn "ashrsi3_cnt1_carry" + [(set (reg:CC_C CC_REG) + (unspec:CC_C [(and:SI (match_operand:SI 1 "register_operand" "r") + (const_int 1))] UNSPEC_ARC_CC_NEZ)) + (set (match_operand:SI 0 "dest_reg_operand" "=r") + (ashiftrt:SI (match_dup 1) (const_int 1)))] + "" + "asr.f\\t%0,%1" + [(set_attr "type" "unary") + (set_attr "length" "4") + (set_attr "predicable" "no")]) + +(define_insn "btst_0_carry" + [(set (reg:CC_C CC_REG) + (unspec:CC_C [(and:SI (match_operand:SI 0 "register_operand" "r") + (const_int 1))] UNSPEC_ARC_CC_NEZ))] + "" + "asr.f\\t0,%0" + [(set_attr "type" "unary") + (set_attr "length" "4") + (set_attr "predicable" "no")]) + (define_peephole2 [(set (match_operand:SI 0 "register_operand" "") (zero_extract:SI (match_dup 0) diff --git a/gcc/testsuite/gcc.target/arc/ashrdi3-1.c b/gcc/testsuite/gcc.target/arc/ashrdi3-1.c new file mode 100644 index 0000000..d990bfd --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/ashrdi3-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +long long foo(long long x) +{ + return x >> 1; +} + +/* { dg-final { scan-assembler "asr.f\\s+r1,r1" } } */ +/* { dg-final { scan-assembler "rrc\\s+r0,r0" } } */ diff --git a/gcc/testsuite/gcc.target/arc/lshrdi3-1.c b/gcc/testsuite/gcc.target/arc/lshrdi3-1.c new file mode 100644 index 0000000..6542ffd --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/lshrdi3-1.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned long long foo(unsigned long long x) +{ + return x >> 1; +} + +/* { dg-final { scan-assembler "lsr.f\\s+r1,r1" } } */ +/* { dg-final { scan-assembler "rrc\\s+r0,r0" } } */ diff --git a/gcc/testsuite/gcc.target/arc/rotldi3-1.c b/gcc/testsuite/gcc.target/arc/rotldi3-1.c new file mode 100644 index 0000000..325996e --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/rotldi3-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned long long foo(unsigned long long x) +{ + return (x << 1) | (x >> 63); +} + +/* { dg-final { scan-assembler "add.f\\s+r0,r0,r0" } } */ +/* { dg-final { scan-assembler "adc.f\\s+r1,r1,r1" } } */ +/* { dg-final { scan-assembler "add.cs\\s+r0,r0,1" } } */ diff --git a/gcc/testsuite/gcc.target/arc/rotrdi3-1.c b/gcc/testsuite/gcc.target/arc/rotrdi3-1.c new file mode 100644 index 0000000..cd8e0de --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/rotrdi3-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned long long foo(unsigned long long x) +{ + return (x >> 1) | (x << 63); +} + +/* { dg-final { scan-assembler "asr.f\\s+0,r0" } } */ +/* { dg-final { scan-assembler "rrc.f\\s+r1,r1" } } */ +/* { dg-final { scan-assembler "rrc\\s+r0,r0" } } */