Compiler predicate optimizations

Viewed 228

Consider the following example conditions/predicates:

  1. x > 10 and x > 20
  2. (x > 10 or x == 10) and (x < 10 or x == 10) aka x >= 10 and x <= 10

Predicate 1. can be simplified to x > 20 and 2. can be simplified to x == 10. Would a compiler optimize this kind of (or more complex) predicates and if so what algorithms are used to do so?

What are some common optimization techniques for predicates?

2 Answers
Related