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