1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

LoadExpr: Set CF_FORCECHAR if test is required

If we are testing, we do not need to load the high byte(s).
This commit is contained in:
Jesse Rosenstock 2020-08-02 09:03:21 +02:00 committed by Oliver Schmidt
parent 2a555d198c
commit adda28f5c5

View File

@ -127,12 +127,19 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
Flags |= TypeOf (Expr->Type);
}
/* Setting CF_TEST will cause the load to perform optimizations and not actually load all
** bits of the bit-field, instead just computing the condition codes. Therefore, if
** adjustment is required, we do not set CF_TEST here, but handle it below.
*/
if (ED_NeedsTest (Expr) && !AdjustBitField) {
Flags |= CF_TEST;
if (ED_NeedsTest (Expr)) {
/* If we're only testing, we do not need to promote char to int.
** CF_FORCECHAR does nothing if the type is not CF_CHAR.
*/
Flags |= CF_FORCECHAR;
/* Setting CF_TEST will cause the load to perform optimizations and not actually load
** all bits of the bit-field, instead just computing the condition codes. Therefore,
** if adjustment is required, we do not set CF_TEST here, but handle it below.
*/
if (!AdjustBitField) {
Flags |= CF_TEST;
}
}
/* Load the content of Expr */
@ -206,7 +213,6 @@ void LoadExpr (unsigned Flags, struct ExprDesc* Expr)
if (AdjustBitField) {
/* If the field was loaded as a char, force the shift/mask ops to be char ops.
** If it is a char, the load has already put 0 in the upper byte, so that can remain.
** CF_FORCECHAR does nothing if the type is not CF_CHAR.
*/
unsigned F = Flags | CF_FORCECHAR | CF_CONST;