mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-30 12:20:06 +08:00
Fix bitfield loads into char/short.
Removes a premature optimization of char/short loads rewriting the source type. It did so also for bitfield loads, thereby removing all the shifts/maskings.
This commit is contained in:
parent
6471ec0a2b
commit
5c0a2366a3
5
tccgen.c
5
tccgen.c
@ -2320,8 +2320,9 @@ ST_FUNC void vstore(void)
|
|||||||
ft = vtop[-1].type.t;
|
ft = vtop[-1].type.t;
|
||||||
sbt = vtop->type.t & VT_BTYPE;
|
sbt = vtop->type.t & VT_BTYPE;
|
||||||
dbt = ft & VT_BTYPE;
|
dbt = ft & VT_BTYPE;
|
||||||
if (((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) ||
|
if ((((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) ||
|
||||||
(sbt == VT_INT && dbt == VT_SHORT)) {
|
(sbt == VT_INT && dbt == VT_SHORT))
|
||||||
|
&& !(vtop->type.t & VT_BITFIELD)) {
|
||||||
/* optimize char/short casts */
|
/* optimize char/short casts */
|
||||||
delayed_cast = VT_MUSTCAST;
|
delayed_cast = VT_MUSTCAST;
|
||||||
vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)));
|
vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT)));
|
||||||
|
@ -1461,6 +1461,8 @@ void c99_bool_test(void)
|
|||||||
void bitfield_test(void)
|
void bitfield_test(void)
|
||||||
{
|
{
|
||||||
int a;
|
int a;
|
||||||
|
short sa;
|
||||||
|
unsigned char ca;
|
||||||
struct sbf1 {
|
struct sbf1 {
|
||||||
int f1 : 3;
|
int f1 : 3;
|
||||||
int : 2;
|
int : 2;
|
||||||
@ -1482,6 +1484,9 @@ void bitfield_test(void)
|
|||||||
st1.f5++;
|
st1.f5++;
|
||||||
printf("%d %d %d %d %d\n",
|
printf("%d %d %d %d %d\n",
|
||||||
st1.f1, st1.f2, st1.f3, st1.f4, st1.f5);
|
st1.f1, st1.f2, st1.f3, st1.f4, st1.f5);
|
||||||
|
sa = st1.f5;
|
||||||
|
ca = st1.f5;
|
||||||
|
printf("%d %d\n", sa, ca);
|
||||||
|
|
||||||
st1.f1 = 7;
|
st1.f1 = 7;
|
||||||
if (st1.f1 == -1)
|
if (st1.f1 == -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user