AArch64InstrInfo::optimizeCompareInstr has a bug which causes generation of incorrect code. Details can be found here: https://llvm.org/bugs/show_bug.cgi?id=27158
The patch refactors the function to simplify reviewing the fix of the bug. It does not fix the bug. It preserves the original behaviour.
The fix of the bug will be submitted later.
- Function name ‘modifiesConditionCode’ is changed to ‘areCFlagsAccessedBetweenInstrs’ to reflect that the function can check modifying accesses, reading accesses or both.
- Function ‘AArch64InstrInfo::optimizeCompareInstr’
- Documented the function
- Cmp_NZCV is DeadNZCVIdx to reflect that it is an operand index of dead NZCV
- The code for the case of substituting CmpInstr is put into separate functions the main of them is ‘substituteCmpInstr’.