@@ -244,7 +244,7 @@ impl EquivalenceClasses {
244
244
stable = self . minimize_once ( columns) ;
245
245
}
246
246
247
- // TODO: remove these measures once we are more confidence about idempotence.
247
+ // TODO: remove these measures once we are more confident about idempotence.
248
248
let prev = self . clone ( ) ;
249
249
self . minimize_once ( columns) ;
250
250
assert_eq ! ( self , & prev) ;
@@ -340,9 +340,7 @@ impl EquivalenceClasses {
340
340
}
341
341
} ) ;
342
342
for expr in class. iter ( ) {
343
- // If Eq(x, y) must be true, we can introduce classes `[x, y]` and `[false, IsNull(x), IsNull(y)]`.
344
- // This substitution replaces a complex expression with several smaller expressions, and cannot
345
- // cycle if we follow that practice.
343
+ // If TRUE == NOT(X) then FALSE == X is a simpler form.
346
344
if let MirScalarExpr :: CallUnary {
347
345
func : mz_expr:: UnaryFunc :: Not ( _) ,
348
346
expr : e,
@@ -366,9 +364,7 @@ impl EquivalenceClasses {
366
364
}
367
365
if class. iter ( ) . any ( |c| c. is_literal_false ( ) ) {
368
366
for expr in class. iter ( ) {
369
- // If Eq(x, y) must be true, we can introduce classes `[x, y]` and `[false, IsNull(x), IsNull(y)]`.
370
- // This substitution replaces a complex expression with several smaller expressions, and cannot
371
- // cycle if we follow that practice.
367
+ // If FALSE == NOT(X) then TRUE == X is a simpler form.
372
368
if let MirScalarExpr :: CallUnary {
373
369
func : mz_expr:: UnaryFunc :: Not ( _) ,
374
370
expr : e,
@@ -556,8 +552,9 @@ impl EquivalenceClasses {
556
552
simplified = self . reduce_expr ( expr) || simplified;
557
553
}
558
554
}
559
- MirScalarExpr :: If { cond, then, els } => {
560
- simplified = self . reduce_expr ( cond) || simplified;
555
+ MirScalarExpr :: If { cond : _, then, els } => {
556
+ // Do not simplify `cond`, as we cannot ensure the simplification
557
+ // continues to hold as expressions migrate around.
561
558
simplified = self . reduce_expr ( then) || simplified;
562
559
simplified = self . reduce_expr ( els) || simplified;
563
560
}
0 commit comments