diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 65ee2281c29..f5d49d07d70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-02-26 Martin Sebor + + PR tree-optimization/15826 + * gcc.dg/tree-ssa/pr15826.c: New test. + 2016-02-26 Jakub Jelinek PR target/69969 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr15826.c b/gcc/testsuite/gcc.dg/tree-ssa/pr15826.c new file mode 100644 index 00000000000..99ac0e2cc58 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr15826.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/15826 - don't use "if" to extract a single bit + bit-field */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +struct s { + unsigned int bit : 1; +}; + +unsigned int +foo (struct s *p) +{ + if (p->bit) + return 1; + else + return 0; +} + +unsigned int +bar (struct s *p) +{ + return (unsigned int) (p->bit); +} + +unsigned int +andrew (struct s *p) +{ + int i; + if (p->bit) + i = 1; + else + i = 0; + return i; +} + +/* { dg-final { scan-tree-dump-times " & | goto " 0 "optimized" } } */