Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.target / sh / pr49468-si.c
1 /* Check that 32 bit integer abs is generated as neg instruction and
2    conditional branch instead of default branch-free code.  */
3 /* { dg-do compile { target "sh*-*-*" } } */
4 /* { dg-options "-O1" } */
5 /* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } }  */
6 /* { dg-final { scan-assembler-times "neg" 2 } } */
7
8
9 /* Normal integer absolute value.  */
10 int
11 abs_0 (int i)
12 {
13   return (i < 0) ? -i : i;
14 }
15
16 /*  Negated integer absolute value.
17     The generated code should be the same, except that the branch 
18     condition is inverted.  */
19 int
20 abs_1 (int i)
21 {
22   return (i > 0) ? -i : i;
23 }