Fix mis-optimization of "expression && non-zero constant" operations with 32-bit type.

The previous code may have been intended to convert this to a "!=0" test, which would have been valid if correctly implemented, but with the current code generator that actually yields worse code than the original version, so for now I just removed the optimization for this case.

This problem could lead to crashes in code like the following (derived from a csmith-generated test case):

#pragma optimize 1
int main(int argc, char *argv[]){
    long l_57 = argc;

    return (4 ^ l_57) && 6;
}
This commit is contained in:
Stephen Heumann 2018-03-26 18:30:45 -05:00
parent db98f7842d
commit 7f94876fa8
1 changed files with 1 additions and 3 deletions

View File

@ -1569,9 +1569,7 @@ case op^.opcode of {check for optimizations of this node}
end; {with}
opv := op^.right;
end; {if}
end {if}
else
op^.opcode := pc_neq;
end; {if}
end; {if}
end {if}
else if op^.left^.opcode = pc_ldc then