This is a revised version of http://reviews.llvm.org/D8232.
It turned out the logic in isConjunctionDisjunctionTree() and emitConjunctionDisjunctionTree() is trickier when it comes to OR-expressions so I think another review is warranted for the update. There is a detailed explanation of the types of expressions that can and cannot be matched now. The patch also adds more testcases for the tricky situations. Everything else is the same as in the previous version.