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.
Unified · Split
| @@ -2320,8 +2320,9 @@ ST_FUNC void vstore(void) · 2319 unmodified lines | ||
| 2320 | 2320 | ft = vtop[-1].type.t; |
| 2321 | 2321 | sbt = vtop->type.t & VT_BTYPE; |
| 2322 | 2322 | dbt = ft & VT_BTYPE; |
| 2323 | − if (((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) || | |
| 2324 | − (sbt == VT_INT && dbt == VT_SHORT)) { | |
| 2323 | + if ((((sbt == VT_INT || sbt == VT_SHORT) && dbt == VT_BYTE) || | |
| 2324 | + (sbt == VT_INT && dbt == VT_SHORT)) | |
| 2325 | + && !(vtop->type.t & VT_BITFIELD)) { | |
| 2325 | 2326 | /* optimize char/short casts */ |
| 2326 | 2327 | delayed_cast = VT_MUSTCAST; |
| 2327 | 2328 | vtop->type.t = ft & (VT_TYPE & ~(VT_BITFIELD | (-1 << VT_STRUCT_SHIFT))); |
| @@ -1461,6 +1461,8 @@ void c99_bool_test(void) · 1460 unmodified lines | ||
| 1461 | 1461 | void bitfield_test(void) |
| 1462 | 1462 | { |
| 1463 | 1463 | int a; |
| 1464 | + short sa; | |
| 1465 | + unsigned char ca; | |
| 1464 | 1466 | struct sbf1 { |
| 1465 | 1467 | int f1 : 3; |
| 1466 | 1468 | int : 2; |
| @@ -1482,6 +1484,9 @@ void bitfield_test(void) · 15 unmodified lines | ||
| 1482 | 1484 | st1.f5++; |
| 1483 | 1485 | printf("%d %d %d %d %d\n", |
| 1484 | 1486 | st1.f1, st1.f2, st1.f3, st1.f4, st1.f5); |
| 1487 | + sa = st1.f5; | |
| 1488 | + ca = st1.f5; | |
| 1489 | + printf("%d %d\n", sa, ca); | |
| 1485 | 1490 | |
| 1486 | 1491 | st1.f1 = 7; |
| 1487 | 1492 | if (st1.f1 == -1) |