Debian Codegraph @

gcc/testsuite/gcc.target/riscv/slt-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-march=rv64gc -mabi=lp64d" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" "-Og" } } */
4
5 #include <stdint.h>
6
7 #define COMPARISON(TYPE, OP, OPN, RESULT_TRUE, RESULT_FALSE) \
8 TYPE test_##OPN(TYPE x, TYPE y) { \
9 return (x OP y) ? RESULT_TRUE : RESULT_FALSE; \
10 }
11
12 /* Signed comparisons */
13 COMPARISON(int64_t, >, GT1, 2, 3)
14 COMPARISON(int64_t, >, GT2, 5, 6)
15
16 COMPARISON(int64_t, <, LT1, 2, 3)
17 COMPARISON(int64_t, <, LT2, 5, 6)
18
19 COMPARISON(int64_t, >=, GE1, 3, 2)
20 COMPARISON(int64_t, >=, GE2, 6, 5)
21
22 COMPARISON(int64_t, <=, LE1, 3, 2)
23 COMPARISON(int64_t, <=, LE2, 6, 5)
24
25 /* Unsigned comparisons */
26 COMPARISON(uint64_t, >, GTU1, 2, 3)
27 COMPARISON(uint64_t, >, GTU2, 5, 6)
28
29 COMPARISON(uint64_t, <, LTU1, 2, 3)
30 COMPARISON(uint64_t, <, LTU2, 5, 6)
31
32 COMPARISON(uint64_t, >=, GEU1, 3, 2)
33 COMPARISON(uint64_t, >=, GEU2, 6, 5)
34
35 COMPARISON(uint64_t, <=, LEU1, 3, 2)
36 COMPARISON(uint64_t, <=, LEU2, 6, 5)
37
38 #define COMPARISON_IMM(TYPE, OP, OPN, RESULT_TRUE, RESULT_FALSE) \
39 TYPE testIMM_##OPN(TYPE x) { \
40 return (x OP -3) ? RESULT_TRUE : RESULT_FALSE; \
41 }
42
43 /* Signed comparisons with immediate */
44 COMPARISON_IMM(int64_t, >, GT1, 3, 2)
45
46 COMPARISON_IMM(int64_t, <, LT1, 2, 3)
47
48 COMPARISON_IMM(int64_t, >=, GE1, 3, 2)
49
50 COMPARISON_IMM(int64_t, <=, LE1, 2, 3)
51
52 /* { dg-final { scan-assembler-times "sgt\\t" 4 } } */
53 /* { dg-final { scan-assembler-times "sgtu\\t" 4 } } */
54 /* { dg-final { scan-assembler-times "slt\\t" 4 } } */
55 /* { dg-final { scan-assembler-times "sltu\\t" 4 } } */
56 /* { dg-final { scan-assembler-times "slti\\t" 4 } } */
57 /* { dg-final { scan-assembler-times "xori\\ta0,a0,1" 8 } } */
58 /* { dg-final { scan-assembler-times "xori\\ta0,a0,3" 12 } } */
59