Article View: gnu.gcc.bug
Article #1085Bug in bitfield operations
From: Andreas Schwab
Date: Tue, 08 Sep 1992 13:24
Date: Tue, 08 Sep 1992 13:24
87 lines
2378 bytes
2378 bytes
Version: GCC 2.2.2 (m68k, sun3)
There is a bug in the optimizer for bitfield operations.
bug.c:
--------------------
struct term
{
unsigned state: 1;
unsigned info: 7;
unsigned content: 24;
};
f (struct term t)
{
struct term t1[1], t2[1]; /* force into memory */
t1[0] = t;
g ((char) t1->content);
t2[0] = t;
g ((short) t2->content);
}
--------------------
Compile with: gcc -O -S bug.c
bug.s:
--------------------
#NO_APP
gcc2_compiled.:
.text
.even
.globl _f
_f:
link a6,#-8
movel a2,sp@-
movel d2,sp@-
movel a6@(8),d2
movel d2,a6@(-4)
moveb a6@(-2),d1 | <--- wrong
extbl d1
movel d1,sp@-
lea _g,a2
jbsr a2@
addqw #4,sp
movel d2,a6@(-8)
bfexts a6@(-6){#0:#16},d1
movel d1,sp@-
jbsr a2@
movel a6@(-16),d2
movel a6@(-12),a2
unlk a6
rts
--------------------
The bug occurs in the combine pass, where these insns
-------------------- (bug.c.flow)
(insn 13 11 14 (set (reg:SI 31)
(zero_extract:SI (mem/s:QI (plus:SI (reg:SI 14)
(const_int -3)))
(const_int 24)
(const_int 0))) 233 {extzv} (nil)
(nil))
(insn 14 13 16 (set (reg:SI 32)
(sign_extend:SI (subreg:QI (reg:SI 31) 0))) 49 {extendqisi2} (insn_list 13 (nil))
(expr_list:REG_DEAD (reg:SI 31)
(nil)))
(insn 16 14 18 (set (mem:SI (pre_dec:SI (reg:SI 15)))
(reg:SI 32)) 29 {movsi+1} (insn_list 14 (nil))
(expr_list:REG_DEAD (reg:SI 32)
(nil)))
--------------------
are combined into ((const_int -2) is wrong)
-------------------- (bug.c.combine)
(insn 16 14 18 (set (mem:SI (pre_dec:SI (reg:SI 15)))
(sign_extend:SI (mem/s:QI (plus:SI (reg:SI 14)
(const_int -2))))) 49 {extendqisi2} (nil)
(nil))
--------------------
--
Andreas Schwab
schwab@ls5.informatik.uni-dortmund.de
Technical Details
Message-ID:
<9209080924.AA21541@lamothe.informatik.uni-dortmund.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!lamothe.informatik.uni-dortmund.de!schwabShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!lamothe.informatik.uni-dortmund.de!schwab From: schwab@lamothe.informatik.uni-dortmund.de (Andreas Schwab) Subject: Bug in bitfield operations Message-ID: <9209080924.AA21541@lamothe.informatik.uni-dortmund.de> Sender: gnulists@ai.mit.edu Reply-To: schwab@ls5.informatik.uni-dortmund.de (Andreas Schwab) Organization: GNUs Not Usenet Distribution: gnu Date: Tue, 8 Sep 1992 13:24:39 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 88