In general I'm a fan of using IR level passes to do some incremental lowering - especially in cases where it makes sense. Don't know if you want fussy feedback on the actual patch here, but it seems like a good direction to me. http://llvm-reviews.chandlerc.com/D3189