view gcc/testsuite/gcc.target/sh/pr49468-si.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* 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-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;
}