I've posted an improved patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141117/245415.html This should swap the operands and still work with unordered compares