aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/sh/pr49468-si.c
blob: 8c771ed20b67b429575790bfb53ce8bf6769d454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* Check that 32 bit integer abs is generated as neg instruction and
   conditional branch instead of default branch-free code.  */
/* { dg-do compile }  */
/* { dg-options "-O1" } */
/* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } }  */
/* { dg-final { scan-assembler-times "neg" 2 } } */


/* Normal integer absolute value.  */
int
abs_0 (int i)
{
  return (i < 0) ? -i : i;
}

/*  Negated integer absolute value.
    The generated code should be the same, except that the branch 
    condition is inverted.  */
int
abs_1 (int i)
{
  return (i > 0) ? -i : i;
}