PR tree-optimization/15826 - don't use "if" to extract a single bit

PR tree-optimization/15826 - don't use "if" to extract a single bit
	bit-field
2016-02-26  Martin Sebor  <msebor@redhat.com>

        PR tree-optimization/15826
        * gcc.dg/tree-ssa/pr15826.c: New test.

From-SVN: r233771
This commit is contained in:
Martin Sebor 2016-02-26 23:24:29 +00:00 committed by Martin Sebor
parent e6fb01b00c
commit 20ba5f3318
2 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2016-02-26 Martin Sebor <msebor@redhat.com>
PR tree-optimization/15826
* gcc.dg/tree-ssa/pr15826.c: New test.
2016-02-26 Jakub Jelinek <jakub@redhat.com>
PR target/69969

View File

@ -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" } } */