C++: Recurse through 'LogicalNotInstruction' in 'getConstantValue'.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-11-23 16:31:57 +00:00
parent 98bf748e64
commit cc261bfabb

View File

@@ -12,6 +12,9 @@ int getConstantValue(Instruction instr) {
or
result = getConstantValue(instr.(CopyInstruction).getSourceValue())
or
getConstantValue(instr.(LogicalNotInstruction).getUnary()) != 0 and
result = 0
or
exists(PhiInstruction phi |
phi = instr and
result = unique(Operand op | op = phi.getAnInputOperand() | getConstantValue(op.getDef()))
@@ -26,9 +29,7 @@ private predicate binaryInstructionOperands(BinaryInstruction instr, int left, i
pragma[noinline]
private int getBinaryInstructionValue(BinaryInstruction instr) {
exists(int left, int right |
binaryInstructionOperands(instr, left, right) and
(
exists(int left, int right | binaryInstructionOperands(instr, left, right) |
instr instanceof AddInstruction and result = add(left, right)
or
instr instanceof SubInstruction and result = sub(left, right)
@@ -49,5 +50,4 @@ private int getBinaryInstructionValue(BinaryInstruction instr) {
or
instr instanceof CompareGEInstruction and result = compareGE(left, right)
)
)
}