aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/pr121116.c
blob: 637324fb4fdebad9358b14850312bd03ead1b092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* { dg-do run { target bitint } } */

#include <stdlib.h>
#include <stdckdint.h>
#include <string.h>
typedef _BitInt(16) bit16;
[[nodiscard]] static bit16 process_data(bit16 input) {
    _Static_assert(sizeof(bit16) == 2, "Unexpected size of bit16");
    return (input << 5) | (input >> 9);
}
int main(void) {
    const bit16 data = 0b101'0101'0000'0000;
    bit16 result = 0;
    for (bit16 i = 0; i < 0b1000; ++i) {
        result ^= process_data(data ^ i);
    }
    if (ckd_add(&result, result, 0x1234)) {
        return EXIT_FAILURE;
    }
    return (result & 0xFF00) ? 0 : 1;
}