Skip to content

Optimization 8bit flag calculation #249

Description

@sabastiaan

For 8-bit instructions that touch flags like add al, al / 00 c0 we currently have 4 separate OR checks to check if the 3rd bit of a value is 1. This on both x86 and amd64.
or-opt2

We can optimize this in two ways, we can:
extract the 3rd bit of advice and check if that bit set is set through and 1

Or we can optimize the entire select away:
Currently the select represents
if( advice_3rd_bit_is_set) return 0b1000 else return 0
Notice that this is equivalent to:

advice_third_bit = extract(advice, 3,2)
XOR(advice_third_bit, 1) << 1 

Leaving us with only XOR << and extract which all should be free on a circuit level I believe.

Metadata

Metadata

Assignees

Labels

optimizationsRelated to circIR optimizationswipCurrently being worked on

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions