[X86][NFC] Minor improvement in X86InstrInfo::optimizeCompareInstr
authorShengchen Kan <shengchen.kan@intel.com>
Mon, 21 Nov 2022 12:59:22 +0000 (20:59 +0800)
committerShengchen Kan <shengchen.kan@intel.com>
Mon, 21 Nov 2022 13:00:07 +0000 (21:00 +0800)
commit861f5dd688c19d206cc44718be9ff75894065d46
treee8a9d35a0afb9178b3af202ab95ab63bfb52f912
parent2a3ac7fd0c9e25ecad272243dabc155e348f2910
[X86][NFC] Minor improvement in X86InstrInfo::optimizeCompareInstr

Before this patch, the code enumerated `getCondFromBranch`, `getCondFromSETCC` and `getCondFromFromCMov` to get the condition code of a `MachineInstr`, and assigned the result to variable `OldCC` when `MI || IsSwapped || ImmDelta != 0` was satisfiled.

After this patch, the `if-else` structure is eliminated by using `getCondFromMI`. Since `OldCC` is only used when  `MI || IsSwapped || ImmDelta != 0`  is true, it is initialized with `getCondFromMI` directly outside the scope of `if` now.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D138349
llvm/lib/Target/X86/X86InstrInfo.cpp