From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27149 invoked by alias); 4 Jun 2004 19:26:17 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 27133 invoked by uid 48); 4 Jun 2004 19:26:16 -0000 Date: Fri, 04 Jun 2004 19:26:00 -0000 Message-ID: <20040604192616.27132.qmail@sourceware.org> From: "pinskia at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040604185552.15826.kazu@cs.umass.edu> References: <20040604185552.15826.kazu@cs.umass.edu> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug tree-optimization/15826] don't use "if" to extract a single bit bit-field. X-Bugzilla-Reason: CC X-SW-Source: 2004-06/txt/msg00496.txt.bz2 List-Id: ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-04 19:26 ------- Here is another example: struct s { unsigned int bit : 1; }; unsigned int foo (struct s *p) { int i; if (p->bit) i = 1; else i = 0; return i; } I will note that the example in comment #1 needs to have the return values merged together before the real optimization happens (see PR 15268 and a patch which I posted but have not gotten around to answering/tying RTH's question/seguestion yet). But basically it can be optimization by putting a cast to bool first so a != 0 becomes (bool)a and PHI- opt already optimizated out the branches. -- What |Removed |Added ---------------------------------------------------------------------------- BugsThisDependsOn| |15268 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15826