public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/19331] New: [4.0 Regression] Inefficient code generated for bitfield assignment
@ 2005-01-08 18:24 giovannibajo at libero dot it
  2005-01-08 18:24 ` [Bug rtl-optimization/19331] " giovannibajo at libero dot it
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: giovannibajo at libero dot it @ 2005-01-08 18:24 UTC (permalink / raw)
  To: gcc-bugs

The attached testcase shows a code generation regression which can be seen on 
x86 but I believe it to be target indepedent.

The code is copying data between two structures, both of which contain 
bitfields. The source structure uses 1-bit bitfields of type "int", while the 
destination structure uses 1-bit bitfields of type "_Bool". At the end of the 
tree optimizers, the code looks like this:

    params.cliplmt_ch1 = (int) msg.cliplmt_ch1 != 0;
    params.cliplmt_ch2 = (int) msg.cliplmt_ch2 != 0;
    params.gate_ch1 = (int) msg.gate_ch1 != 0;
    params.gate_ch2 = (int) msg.gate_ch2 != 0;

The problem is that the comparison with zero is never removed by the 
optimizers. The generated code looks like this:

	testb	$1, %bl
	setne	%cl

In 3.4, instead, the generated code looks better:

	andl	$1, %ebx



Notice this this does not happen in C++ (using a "bool" bitfield instead 
of "_Bool"). We get a BITFIELD_REF there:

    D.1643 = BIT_FIELD_REF <msg, 8, 40>;
    params.cliplmt_ch1 = (D.1643 & 1) != 0;
    params.cliplmt_ch2 = (D.1643 & 2) != 0;
    params.gate_ch1 = (D.1643 & 4) != 0;
    params.gate_ch2 = (D.1643 & 8) != 0;

and the generated code is optimal.

-- 
           Summary: [4.0 Regression] Inefficient code generated for bitfield
                    assignment
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: giovannibajo at libero dot it
                CC: aleph at develer dot com,bernie at develer dot com,gcc-
                    bugs at gcc dot gnu dot org,sayle at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19331


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2005-03-14  3:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-08 18:24 [Bug rtl-optimization/19331] New: [4.0 Regression] Inefficient code generated for bitfield assignment giovannibajo at libero dot it
2005-01-08 18:24 ` [Bug rtl-optimization/19331] " giovannibajo at libero dot it
2005-01-08 18:26 ` pinskia at gcc dot gnu dot org
2005-01-08 18:27 ` giovannibajo at libero dot it
2005-01-08 18:28 ` giovannibajo at libero dot it
2005-01-08 18:28 ` [Bug middle-end/19331] " giovannibajo at libero dot it
2005-01-08 18:28 ` pinskia at gcc dot gnu dot org
2005-01-08 18:37 ` pinskia at gcc dot gnu dot org
2005-01-08 19:02 ` pinskia at gcc dot gnu dot org
2005-01-27  0:23 ` steven at gcc dot gnu dot org
2005-02-01  0:33 ` pinskia at gcc dot gnu dot org
2005-02-01  5:57 ` pinskia at gcc dot gnu dot org
2005-03-13 15:08 ` [Bug middle-end/19331] [4.0/4.1 " giovannibajo at libero dot it
2005-03-13 22:34 ` cvs-commit at gcc dot gnu dot org
2005-03-13 23:29 ` [Bug middle-end/19331] [4.0 " pinskia at gcc dot gnu dot org
2005-03-14  3:49 ` cvs-commit at gcc dot gnu dot org
2005-03-14  3:58 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).