This adds all the support for top-down traversals and constant prefolding that was
reverted in this patch:
https://reviews.llvm.org/D99329
This has two changes from the previous patch:
- It disables the 'processExistingConstants' prefolding call when doing a bottom-up traversal.
- It defaults applyPatternsAndFoldGreedily to bottom-up traversal instead of top-down.
The consequence of these two changes is that there is *no behavior change* from this
patch. We can stage in the new behavior on a case by case basis over time.
It's "pre-order over the region tree" because the old scheme is doing post-order + reverse which would be pre-order since this is a directed tree. With the new scheme, you are doing pre-order + reverse + reverse, which is again pre-order. The original traversal is post order but since the rewriter is popping from the end, we might refer to the combined thing here?