X86InstrInfo::optimizeCompareInstr would only optimize a SUB followed by a CMP in isRedundantFlagInstr. This extends the code to also look for other combinations like CMP+CMP, TEST+TEST, SUB x,0+TEST.
- Change isRedundantFlagInstr to run analyzeCompareInstr on the candidate instruction and compare the results. This normalizes things and gives consistent results for various comparisons (CMP x, y, SUB x, y) and immediate cases (TEST x, x, SUB x, 0, CMP x, 0...).
- Turn isRedundantFlagInstr into a member function so it can call analyzeCompare.
- We now also check isRedundantFlagInstr even if IsCmpZero is true, since we now have cases like TEST+TEST.