From patchwork Fri Feb 17 08:35:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Zhu X-Patchwork-Id: 58413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp770287wrn; Fri, 17 Feb 2023 00:36:42 -0800 (PST) X-Google-Smtp-Source: AK7set/CD5Q1YsfjHizOFdoXIsDlCJK7ZPQMd9uYKQ7oTnB68O8GjFaTm/yWadug3wmT29ZeZdBf X-Received: by 2002:aa7:c797:0:b0:4ac:bbd8:d04a with SMTP id n23-20020aa7c797000000b004acbbd8d04amr464439eds.5.1676623002025; Fri, 17 Feb 2023 00:36:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676623002; cv=none; d=google.com; s=arc-20160816; b=fkXcIvG0G/rmTNxZeGIh41U2UfZaSNv3H1QTK5u0JIy5ztiiYn2r/YHPo7oR8+cnut Sy6wHMRg+PB0ArBSLLFkg7apfX9UHPsdNO/EVlAkGmRikAnE1cQplg4xuwJnCq48dNLY 6+zTWxt/LXdp6FcVWfK20+N0wTj7FVnLC9I9eJMHF9Gv2k3O2iBQ8gCjOz/4p6Y2PS+Z udOqMrNfKynvsHxf3gf0f2bvjqnYlK44+twOHWo+CPrTKyaOzSejEJKPgRjyJ8fZMAoi uASBoTYgwxD5h5XnjrhqYM8YMjJOTW91CiXS0jgRF5sMxNlTiUYGDGh7m4DP65tzr1Tg MP0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:from :date:cc:message-id:to:mime-version:subject:dkim-signature :dmarc-filter:delivered-to; bh=y7fuMKHGNt2sHuK22d7zW9SdFNKP5Pi6jcY8VRqSVhg=; b=fKIdks8dpoowMDmVRXQLORSkWKzY4j3V7GVxEZMyLJFHUgwALQkS8gkypCGDF+NlYO 10pwARQowFvz0DxXC2l1SJJa5KlPS1bp4OJyXCdq3FGDlZTY9HONL4vLoTT/7fPRTrwY lPRVYTllBIwxrd9TD+R6LHfiXpm69vcU8tLmfpDnMN+0xUJH4WGPXGUwhkKNuQLw+am3 oulY9l2/0SaF/vqYVj5FboFpFc2PCsPz4jzmMVsNWMJe6tMjFP/2TA9peorT3AwsCbQr pif2XAkopCZMsmA+BFOtHcxvzIa3AlN/Fgw0m7BzEjr7iKJh7WAANeqH/7yCrZk8QoxQ 0MwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@oss-cipunited-com.20200927.dkim.feishu.cn header.s=s1 header.b=OfVOgp2Z; 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id bm22-20020a0564020b1600b004ad0c8c8275si4726406edb.282.2023.02.17.00.36.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 00:36:42 -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=neutral (body hash did not verify) header.i=@oss-cipunited-com.20200927.dkim.feishu.cn header.s=s1 header.b=OfVOgp2Z; 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 7F4B5386187B for ; Fri, 17 Feb 2023 08:36:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from t04.bc.larksuite.com (t04.bc.larksuite.com [209.127.231.40]) by sourceware.org (Postfix) with UTF8SMTPS id 254513858C78 for ; Fri, 17 Feb 2023 08:36:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 254513858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=oss.cipunited.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=oss.cipunited.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=oss-cipunited-com.20200927.dkim.feishu.cn; t=1676622967; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=OFeRUHFRB0L6XaHs+xC26OBf2k7D2fWWxYw5xoFbh9Y=; b=OfVOgp2Z68B2TcE90ObD+ebtqxtk2LOX2+ZP/pYxzsahLO4IpJt6EekycwYHtJhqOqI6bK 0LZL7cS1KdbOlNtOLbKAo7N6tjcS3HgDyN9M7ZyrPgJU6FNdjamDUhIglCqqn7Qott7KrX jZ1vm2OC0X9G6AZHhkZoekVuY4vSNCaLM5OvmXOOi2qZyg358Zx+BRrXSCvBxp9RczUrA0 yECTZbz/LRC0OCel+v5tw9igkFZtrYGYCdUsF8dLF1k3DsbWOssPsdlTRj05+GKS6D05e7 q+8Py65rtQHLyww9yN3v0lLrJCVGcJxivIKd2AoWryJUxRXxM+NSUb41Y7fECQ== Subject: [PATCH] Add pattern for clo Mime-Version: 1.0 X-Lms-Return-Path: To: X-Original-From: "Junxian Zhu" Message-Id: <20230217083531.3409405-1-zhujunxian@oss.cipunited.com> Cc: , , "Junxian Zhu" Date: Fri, 17 Feb 2023 16:35:56 +0800 From: "Junxian Zhu" X-Mailer: git-send-email 2.39.1 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758066641012508076?= X-GMAIL-MSGID: =?utf-8?q?1758066641012508076?= From: Junxian Zhu gcc/ChangeLog: * config/mips/mips.md (*clo2): New pattern. gcc/testsuite/ChangeLog: * gcc.target/mips/clz.c: New test. * gcc.target/mips/clz.c: New test. * gcc.target/mips/mips.exp: New option HAS_CLZ. Signed-off-by: Junxian Zhu --- gcc/config/mips/mips.md | 9 +++++++++ gcc/testsuite/gcc.target/mips/clo.c | 11 +++++++++++ gcc/testsuite/gcc.target/mips/clz.c | 10 ++++++++++ gcc/testsuite/gcc.target/mips/mips.exp | 3 +++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.target/mips/clo.c create mode 100644 gcc/testsuite/gcc.target/mips/clz.c diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index e3bf32a3430..10607a57efc 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -3165,6 +3165,15 @@ [(set_attr "type" "clz") (set_attr "mode" "")]) + +(define_insn "*clo2" + [(set (match_operand:GPR 0 "register_operand" "=d") + (clz:GPR (not:GPR (match_operand:GPR 1 "register_operand" "d"))))] + "ISA_HAS_CLZ_CLO" + "clo\t%0,%1" + [(set_attr "type" "clz") + (set_attr "mode" "")]) + ;; ;; ................... ;; diff --git a/gcc/testsuite/gcc.target/mips/clo.c b/gcc/testsuite/gcc.target/mips/clo.c new file mode 100644 index 00000000000..91f29a1322a --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/clo.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "(HAS_CLZ)" } */ +/* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */ + +NOMIPS16 unsigned int foo(unsigned int x) +{ + return __builtin_clz (~x); +} + +/* { dg-final { scan-assembler-not "\tclz\t" } } */ +/* { dg-final { scan-assembler "\tclo\t" } } */ diff --git a/gcc/testsuite/gcc.target/mips/clz.c b/gcc/testsuite/gcc.target/mips/clz.c new file mode 100644 index 00000000000..74e6edb90aa --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/clz.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "(HAS_CLZ)" } */ +/* { dg-skip-if "code quality test" { *-*-* } { "-O0" } { "" } } */ + +NOMIPS16 unsigned int foo(unsigned int x) +{ + return __builtin_clz (x); +} + +/* { dg-final { scan-assembler "\tclz\t" } } */ diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp index 025fbe78359..ac3ab129541 100644 --- a/gcc/testsuite/gcc.target/mips/mips.exp +++ b/gcc/testsuite/gcc.target/mips/mips.exp @@ -252,6 +252,7 @@ set mips_option_groups { warnings "-w" dump "-fdump-.*" ins "HAS_INS" + clz "HAS_CLZ" dmul "NOT_HAS_DMUL" ldc "HAS_LDC" movn "HAS_MOVN" @@ -1198,11 +1199,13 @@ proc mips-dg-options { args } { # # - paired-single instructions(*) # - odd numbered single precision registers + # - clz clo instructions # # (*) Note that we don't support MIPS V at the moment. } elseif { $isa_rev < 1 && ([mips_have_test_option_p options "-mpaired-single"] || ([mips_have_test_option_p options "-modd-spreg"] + || [mips_have_test_option_p options "HAS_CLZ"] && ![mips_have_test_option_p options "-mfp64"]))} { if { $gp_size == 32 } { mips_make_test_option options "-mips32"