File: load_zero.c

package info (click to toggle)
simde 0.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-backports
  • size: 58,264 kB
  • sloc: ansic: 817,393; sh: 315; makefile: 45; python: 26
file content (123 lines) | stat: -rw-r--r-- 5,173 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* Copyright (c) 2021 Evan Nemerson <evan@nemerson.com>
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#define SIMDE_TEST_WASM_SIMD128_INSN load_zero
#include "../../../simde/wasm/simd128.h"
#include "test-simd128.h"

static int
test_simde_wasm_v128_load32_zero(SIMDE_MUNIT_TEST_ARGS) {
  #if 1
    SIMDE_TEST_STRUCT_MODIFIERS struct {
      int32_t a;
      int32_t r[sizeof(simde_v128_t) / sizeof(int16_t)];
    } test_vec[] = {
      { -INT32_C(  1663987737),
        { -INT32_C(  1663987737),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      { -INT32_C(   443825017),
        { -INT32_C(   443825017),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      {  INT32_C(   395819065),
        {  INT32_C(   395819065),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      { -INT32_C(  1306750047),
        { -INT32_C(  1306750047),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      {  INT32_C(  1307801713),
        {  INT32_C(  1307801713),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      { -INT32_C(   478359472),
        { -INT32_C(   478359472),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      {  INT32_C(  1705130081),
        {  INT32_C(  1705130081),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } },
      {  INT32_C(  1894984934),
        {  INT32_C(  1894984934),  INT32_C(           0),  INT32_C(           0),  INT32_C(           0) } }
    };

    for (size_t i = 0 ; i < (sizeof(test_vec) / sizeof(test_vec[0])) ; i++) {
      simde_v128_t r = simde_wasm_v128_load32_zero(&(test_vec[i].a));
      simde_test_wasm_i32x4_assert_equal(r, simde_wasm_v128_load(test_vec[i].r));
    }
    return 0;
  #else
    fputc('\n', stdout);
    for (int i = 0 ; i < 8 ; i++) {
      int32_t a = simde_test_codegen_random_i32();
      simde_v128_t r;

      r = simde_wasm_v128_load32_zero(&a);

      simde_test_codegen_write_i32(3, a, SIMDE_TEST_VEC_POS_FIRST);
      simde_test_wasm_i32x4_write(3, r, SIMDE_TEST_VEC_POS_LAST);
    }
    return 1;
  #endif
}

static int
test_simde_wasm_v128_load64_zero(SIMDE_MUNIT_TEST_ARGS) {
  #if 1
    SIMDE_TEST_STRUCT_MODIFIERS struct {
      int64_t a;
      int64_t r[sizeof(simde_v128_t) / sizeof(int16_t)];
    } test_vec[] = {
      {  INT64_C(  629350488805579936),
        {  INT64_C(  629350488805579936),  INT64_C(                   0) } },
      {  INT64_C( 7989076400909386161),
        {  INT64_C( 7989076400909386161),  INT64_C(                   0) } },
      {  INT64_C( 9067182422419151710),
        {  INT64_C( 9067182422419151710),  INT64_C(                   0) } },
      {  INT64_C(  301869024279662759),
        {  INT64_C(  301869024279662759),  INT64_C(                   0) } },
      { -INT64_C( 7900487491134283995),
        { -INT64_C( 7900487491134283995),  INT64_C(                   0) } },
      {  INT64_C( 5365458524930490530),
        {  INT64_C( 5365458524930490530),  INT64_C(                   0) } },
      { -INT64_C( 1238706882052499426),
        { -INT64_C( 1238706882052499426),  INT64_C(                   0) } },
      { -INT64_C( 7877366110503050539),
        { -INT64_C( 7877366110503050539),  INT64_C(                   0) } }
    };

    for (size_t i = 0 ; i < (sizeof(test_vec) / sizeof(test_vec[0])) ; i++) {
      simde_v128_t r = simde_wasm_v128_load64_zero(&(test_vec[i].a));
      simde_test_wasm_i64x2_assert_equal(r, simde_wasm_v128_load(test_vec[i].r));
    }
    return 0;
  #else
    fputc('\n', stdout);
    for (int i = 0 ; i < 8 ; i++) {
      int64_t a = simde_test_codegen_random_i64();
      simde_v128_t r;

      r = simde_wasm_v128_load64_zero(&a);

      simde_test_codegen_write_i64(3, a, SIMDE_TEST_VEC_POS_FIRST);
      simde_test_wasm_i64x2_write(3, r, SIMDE_TEST_VEC_POS_LAST);
    }
    return 1;
  #endif
}

SIMDE_TEST_FUNC_LIST_BEGIN
  SIMDE_TEST_FUNC_LIST_ENTRY(wasm_v128_load32_zero)
  SIMDE_TEST_FUNC_LIST_ENTRY(wasm_v128_load64_zero)
SIMDE_TEST_FUNC_LIST_END

#include "test-simd128-footer.h"