1 /* Check that eliminable compare-instructions are eliminated. */
2 /* { dg-do compile } */
3 /* { dg-options "-O2" } */
4 /* { dg-final { scan-assembler-not "\tcmp|\ttest" } } */
5 /* { dg-final { scan-assembler "\tneg" } } */
6 
7 void foo(void);
8 
9 #ifndef op
10 #define op(x) -(x)
11 #endif
12 
13 #define f(k, T, T2)				\
14 void f ## k (T *a, T2 *b)			\
15 {						\
16   T2 d = op(*a);				\
17   *b = d;					\
18   if (d != 0)					\
19     foo();					\
20 }
21 
22 #define ff(x, y) f(x, y, y)
23 
24 /* For NEG, gcc prefers to test the source (before the operation), but
25    will settle for the destination.  For SImode, the destination is
26    allocated to a different register than the source.  Not that
27    important; just skip the "int" variant for now.  */
28 #ifndef do_1
29 #define do_1 0
30 #endif
31 
32 #ifndef do_2
33 #define do_2 1
34 #endif
35 #ifndef do_3
36 #define do_3 1
37 #endif
38 
39 #if do_1
40 ff(1, int)
41 #endif
42 
43 #if do_2
44 ff(2, short int)
45 #endif
46 
47 #if do_3
48 ff(3, signed char)
49 #endif
50