From patchwork Tue May 12 20:30:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 48406 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D280B2121F for ; Tue, 12 May 2015 20:33:02 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf4765827lab.1 for ; Tue, 12 May 2015 13:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:sender:delivered-to:from:to:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results; bh=hptYTnIOmqAaIyn3s7X2Q8rul4Z0mSO/kfO7cSGvYoU=; b=NJ7QSAzkDxVzYPwfQ2us0idRwcKE5+pAEHmXxZ5bTTcxPuqmMIo/aCFJB+kH2OJGfR FLbhBFB5boV81if0YtPKldiErTbSZ3oKwqVjjiooCWW1RKThVrvzft8faMrkwN+/SvjM vq3E/22+g0/8pAYtlzYgg74oygM8q9GY93JmkKHRTrDywKOn8Daux+iTGdQXmeuO49m2 oxWLrHYEKVoVJJ3w8RPvjd7yQQ/9Q4APE16cQA9ebMTfSi8+grftDGc4ZI0AUgNK29PT tFjRyV0Tr+e/zQCHm+qFAoFr9auk/Pjat8US7jFpIM8RVDxAuyrG0CBqfPEgDE89myAm oolg== X-Gm-Message-State: ALoCoQlg0xhN2/NaUJl17OYykKv1D5pBmIWZ+PC9G8dGURRu1CdGWkzveJH9ehEO4Ae1Twn9XX6t X-Received: by 10.112.55.104 with SMTP id r8mr11723154lbp.18.1431462781450; Tue, 12 May 2015 13:33:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.73 with SMTP id lm9ls106081lac.20.gmail; Tue, 12 May 2015 13:33:01 -0700 (PDT) X-Received: by 10.112.161.226 with SMTP id xv2mr13501684lbb.106.1431462781317; Tue, 12 May 2015 13:33:01 -0700 (PDT) Received: from mail-lb0-x235.google.com (mail-lb0-x235.google.com. [2a00:1450:4010:c04::235]) by mx.google.com with ESMTPS id ja2si10998402lbc.160.2015.05.12.13.33.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 13:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::235 as permitted sender) client-ip=2a00:1450:4010:c04::235; Received: by lbbuc2 with SMTP id uc2so14857683lbb.2 for ; Tue, 12 May 2015 13:33:01 -0700 (PDT) X-Received: by 10.112.222.133 with SMTP id qm5mr13433902lbc.86.1431462781180; Tue, 12 May 2015 13:33:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp136946lbb; Tue, 12 May 2015 13:33:00 -0700 (PDT) X-Received: by 10.68.116.132 with SMTP id jw4mr31059815pbb.107.1431462779358; Tue, 12 May 2015 13:32:59 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id zj2si14979392pbb.29.2015.05.12.13.32.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 13:32:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-397714-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 75976 invoked by alias); 12 May 2015 20:31:22 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 75922 invoked by uid 89); 12 May 2015 20:31:22 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f50.google.com Received: from mail-wg0-f50.google.com (HELO mail-wg0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 12 May 2015 20:31:19 +0000 Received: by wgnd10 with SMTP id d10so20286180wgn.2 for ; Tue, 12 May 2015 13:31:15 -0700 (PDT) X-Received: by 10.181.13.16 with SMTP id eu16mr7665749wid.10.1431462674951; Tue, 12 May 2015 13:31:14 -0700 (PDT) Received: from babel.clyon.hd.free.fr (vig38-2-82-225-222-175.fbx.proxad.net. [82.225.222.175]) by mx.google.com with ESMTPSA id u9sm24921095wju.44.2015.05.12.13.31.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 May 2015 13:31:14 -0700 (PDT) From: Christophe Lyon To: gcc-patches@gcc.gnu.org Subject: [Patch ARM-AArch64/testsuite Neon intrinsics 05/13] Add vqrdmulh_n tests. Date: Tue, 12 May 2015 22:30:53 +0200 Message-Id: <1431462661-27247-6-git-send-email-christophe.lyon@linaro.org> In-Reply-To: <1431462661-27247-1-git-send-email-christophe.lyon@linaro.org> References: <1431462661-27247-1-git-send-email-christophe.lyon@linaro.org> X-IsSubscribed: yes X-Original-Sender: christophe.lyon@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 diff --git a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_n.c b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_n.c new file mode 100644 index 0000000..fdc739c --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vqrdmulh_n.c @@ -0,0 +1,155 @@ +#include +#include "arm-neon-ref.h" +#include "compute-ref-data.h" + +/* Expected values of cumulative_saturation flag. */ +int VECT_VAR(expected_cumulative_sat,int,16,4) = 0; +int VECT_VAR(expected_cumulative_sat,int,32,2) = 0; +int VECT_VAR(expected_cumulative_sat,int,16,8) = 0; +int VECT_VAR(expected_cumulative_sat,int,32,4) = 0; + +/* Expected results. */ +VECT_VAR_DECL(expected,int,16,4) [] = { 0xfffc, 0xfffc, 0xfffc, 0xfffd }; +VECT_VAR_DECL(expected,int,32,2) [] = { 0xfffffffe, 0xfffffffe }; +VECT_VAR_DECL(expected,int,16,8) [] = { 0x6, 0x6, 0x6, 0x5, + 0x5, 0x4, 0x4, 0x4 }; +VECT_VAR_DECL(expected,int,32,4) [] = { 0xfffffffe, 0xfffffffe, + 0xfffffffe, 0xfffffffe }; + +/* Expected values of cumulative_saturation flag when multiplication + saturates. */ +int VECT_VAR(expected_cumulative_sat_mul,int,16,4) = 1; +int VECT_VAR(expected_cumulative_sat_mul,int,32,2) = 1; +int VECT_VAR(expected_cumulative_sat_mul,int,16,8) = 1; +int VECT_VAR(expected_cumulative_sat_mul,int,32,4) = 1; + +/* Expected results when multiplication saturates. */ +VECT_VAR_DECL(expected_mul,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff }; +VECT_VAR_DECL(expected_mul,int,32,2) [] = { 0x7fffffff, 0x7fffffff }; +VECT_VAR_DECL(expected_mul,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, + 0x7fff, 0x7fff, 0x7fff, 0x7fff }; +VECT_VAR_DECL(expected_mul,int,32,4) [] = { 0x7fffffff, 0x7fffffff, + 0x7fffffff, 0x7fffffff }; + +/* Expected values of cumulative_saturation flag when rounding + should not cause saturation. */ +int VECT_VAR(expected_cumulative_sat_round,int,16,4) = 0; +int VECT_VAR(expected_cumulative_sat_round,int,32,2) = 0; +int VECT_VAR(expected_cumulative_sat_round,int,16,8) = 0; +int VECT_VAR(expected_cumulative_sat_round,int,32,4) = 0; + +/* Expected results when rounding should not cause saturation. */ +VECT_VAR_DECL(expected_round,int,16,4) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff }; +VECT_VAR_DECL(expected_round,int,32,2) [] = { 0x7fffffff, 0x7fffffff }; +VECT_VAR_DECL(expected_round,int,16,8) [] = { 0x7fff, 0x7fff, 0x7fff, 0x7fff, + 0x7fff, 0x7fff, 0x7fff, 0x7fff }; +VECT_VAR_DECL(expected_round,int,32,4) [] = { 0x7fffffff, 0x7fffffff, + 0x7fffffff, 0x7fffffff }; + +#define INSN vqrdmulh +#define TEST_MSG "VQRDMULH_N" + +#define FNNAME1(NAME) void exec_ ## NAME ## _n (void) +#define FNNAME(NAME) FNNAME1(NAME) + +FNNAME (INSN) +{ + int i; + + /* vector_res = vqrdmulh_n(vector,val), then store the result. */ +#define TEST_VQRDMULH_N2(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) \ + Set_Neon_Cumulative_Sat(0, VECT_VAR(vector_res, T1, W, N)); \ + VECT_VAR(vector_res, T1, W, N) = \ + INSN##Q##_n_##T2##W(VECT_VAR(vector, T1, W, N), \ + L); \ + vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \ + VECT_VAR(vector_res, T1, W, N)); \ + CHECK_CUMULATIVE_SAT(TEST_MSG, T1, W, N, EXPECTED_CUMULATIVE_SAT, CMT) + + /* Two auxliary macros are necessary to expand INSN */ +#define TEST_VQRDMULH_N1(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) \ + TEST_VQRDMULH_N2(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) + +#define TEST_VQRDMULH_N(Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) \ + TEST_VQRDMULH_N1(INSN, Q, T1, T2, W, N, L, EXPECTED_CUMULATIVE_SAT, CMT) + + + DECL_VARIABLE(vector, int, 16, 4); + DECL_VARIABLE(vector, int, 32, 2); + DECL_VARIABLE(vector, int, 16, 8); + DECL_VARIABLE(vector, int, 32, 4); + + DECL_VARIABLE(vector_res, int, 16, 4); + DECL_VARIABLE(vector_res, int, 32, 2); + DECL_VARIABLE(vector_res, int, 16, 8); + DECL_VARIABLE(vector_res, int, 32, 4); + + clean_results (); + + VLOAD(vector, buffer, , int, s, 16, 4); + VLOAD(vector, buffer, , int, s, 32, 2); + VLOAD(vector, buffer, q, int, s, 16, 8); + VLOAD(vector, buffer, q, int, s, 32, 4); + + /* Choose multiplier arbitrarily. */ +#define CMT "" + TEST_VQRDMULH_N(, int, s, 16, 4, 0x2233, expected_cumulative_sat, CMT); + TEST_VQRDMULH_N(, int, s, 32, 2, 0x12345678, expected_cumulative_sat, CMT); + TEST_VQRDMULH_N(q, int, s, 16, 8, 0xCD12, expected_cumulative_sat, CMT); + TEST_VQRDMULH_N(q, int, s, 32, 4, 0xFA23456, expected_cumulative_sat, CMT); + + CHECK(TEST_MSG, int, 16, 4, PRIx16, expected, CMT); + CHECK(TEST_MSG, int, 32, 2, PRIx32, expected, CMT); + CHECK(TEST_MSG, int, 16, 8, PRIx16, expected, CMT); + CHECK(TEST_MSG, int, 32, 4, PRIx32, expected, CMT); + + /* Now use input values such that the multiplication causes + saturation. */ +#define TEST_MSG_MUL " (check mul cumulative saturation)" + VDUP(vector, , int, s, 16, 4, 0x8000); + VDUP(vector, , int, s, 32, 2, 0x80000000); + VDUP(vector, q, int, s, 16, 8, 0x8000); + VDUP(vector, q, int, s, 32, 4, 0x80000000); + + TEST_VQRDMULH_N(, int, s, 16, 4, 0x8000, expected_cumulative_sat_mul, + TEST_MSG_MUL); + TEST_VQRDMULH_N(, int, s, 32, 2, 0x80000000, expected_cumulative_sat_mul, + TEST_MSG_MUL); + TEST_VQRDMULH_N(q, int, s, 16, 8, 0x8000, expected_cumulative_sat_mul, + TEST_MSG_MUL); + TEST_VQRDMULH_N(q, int, s, 32, 4, 0x80000000, expected_cumulative_sat_mul, + TEST_MSG_MUL); + + CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_mul, TEST_MSG_MUL); + CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_mul, TEST_MSG_MUL); + CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_mul, TEST_MSG_MUL); + CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_mul, TEST_MSG_MUL); + + /* Use input values where rounding produces a result equal to the + saturation value, but does not set the saturation flag. */ +#define TEST_MSG_ROUND " (check rounding)" + VDUP(vector, , int, s, 16, 4, 0x8000); + VDUP(vector, , int, s, 32, 2, 0x80000000); + VDUP(vector, q, int, s, 16, 8, 0x8000); + VDUP(vector, q, int, s, 32, 4, 0x80000000); + + TEST_VQRDMULH_N(, int, s, 16, 4, 0x8001, expected_cumulative_sat_round, + TEST_MSG_ROUND); + TEST_VQRDMULH_N(, int, s, 32, 2, 0x80000001, expected_cumulative_sat_round, + TEST_MSG_ROUND); + TEST_VQRDMULH_N(q, int, s, 16, 8, 0x8001, expected_cumulative_sat_round, + TEST_MSG_ROUND); + TEST_VQRDMULH_N(q, int, s, 32, 4, 0x80000001, expected_cumulative_sat_round, + TEST_MSG_ROUND); + + CHECK(TEST_MSG, int, 16, 4, PRIx16, expected_round, TEST_MSG_ROUND); + CHECK(TEST_MSG, int, 32, 2, PRIx32, expected_round, TEST_MSG_ROUND); + CHECK(TEST_MSG, int, 16, 8, PRIx16, expected_round, TEST_MSG_ROUND); + CHECK(TEST_MSG, int, 32, 4, PRIx32, expected_round, TEST_MSG_ROUND); +} + +int main (void) +{ + exec_vqrdmulh_n (); + return 0; +}