Skip to content

Commit a897143

Browse files
committed
Add If variants and safer default to PRE hoisting check
Add If/IfI/IfF/IfB to the term_contains_gamma_or_select match list since egglog extraction may return these canonical forms. Also change the None default to true (assume condition-dependent) for safety when parsing fails.
1 parent 7a2e357 commit a897143

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • rust/spirv-tools-opt/src/direct

rust/spirv-tools-opt/src/direct/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ pub fn optimize_module_direct(module: &Module) -> Result<Module, EgglogOptError>
11861186
// which moves the selection below the outermost constructor.
11871187
let contains_gamma_or_select = match parse_sexpr(&gamma_term) {
11881188
Some(ref term) => term_contains_gamma_or_select(term),
1189-
None => false,
1189+
None => true, // Parsing failed — assume condition-dependent, don't hoist
11901190
};
11911191
if !contains_gamma_or_select {
11921192
// The expression can be hoisted!
@@ -2536,6 +2536,10 @@ fn term_contains_gamma_or_select(term: &Term) -> bool {
25362536
| "SelectI"
25372537
| "SelectF"
25382538
| "SelectB"
2539+
| "If"
2540+
| "IfI"
2541+
| "IfF"
2542+
| "IfB"
25392543
) {
25402544
return true;
25412545
}

0 commit comments

Comments
 (0)