Debian Codegraph @

gcc/testsuite/gcc.target/i386/sattrunc-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-final { scan-assembler-times "sbb|cmov" 6 { target { ! ia32 } } } } */
4 /* { dg-final { scan-assembler-times "sbb|cmov" 3 { target ia32 } } } */
5
6 #include <stdint.h>
7
8 #define DEF_SAT_U_TRUNC(WT, NT) \
9 NT sat_u_truc_##WT##_to_##NT (WT x) \
10 { \
11 _Bool overflow = x > (WT)(NT)(-1); \
12 return (NT)x | (NT)-overflow; \
13 }
14
15 #ifdef __x86_64__
16 DEF_SAT_U_TRUNC(uint64_t, uint32_t)
17 DEF_SAT_U_TRUNC(uint64_t, uint16_t)
18 DEF_SAT_U_TRUNC(uint64_t, uint8_t)
19 #endif
20
21 DEF_SAT_U_TRUNC(uint32_t, uint16_t)
22 DEF_SAT_U_TRUNC(uint32_t, uint8_t)
23
24 DEF_SAT_U_TRUNC(uint16_t, uint8_t)