passes: add mba scheme to Constants (and+or+add identity)

(a&b)+(a|b) = a+b, documented honestly: falls to the same symbolic
evaluator as xor/add/shift (every sub-expression is a foldable
LDC,LDC,BINOP triple), but defeats a pattern matcher hardcoded to one
opcode ("ldc,ldc,ixor = split constant"). Added to ConstantsConfig
default schemes.

Tests: mba_form_uses_and_or_add_not_a_single_binop, round-trip coverage
in int_forms_round_trip/long_forms_keep_shape.
This commit is contained in:
Loki 2026-10-14 01:30:10 +02:00
parent 550f62e473
commit 2b19ed6096
Signed by: boba
GPG key ID: 253067914055423B
4 changed files with 133 additions and 10 deletions

View file

@ -124,7 +124,8 @@ impl Default for FlowConfig {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct ConstantsConfig {
/// Splitting schemes (`xor`, `add`, `shift`), picked by RNG per constant.
/// Splitting schemes (`xor`, `add`, `shift`, `mba`), picked by RNG per
/// constant.
pub schemes: Vec<String>,
/// Insert opaque predicates (at most this many per method).
pub max_predicates: usize,
@ -135,7 +136,12 @@ pub struct ConstantsConfig {
impl Default for ConstantsConfig {
fn default() -> Self {
Self {
schemes: vec!["xor".to_string(), "add".to_string(), "shift".to_string()],
schemes: vec![
"xor".to_string(),
"add".to_string(),
"shift".to_string(),
"mba".to_string(),
],
max_predicates: 1,
skip: Vec::new(),
}