[PATCH] D118663: [AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 7 04:31:06 PST 2022
dmgreen added a comment.
Someone once wrote examineCFlagsUse for doing something very similar in the optimizeCompareInstr (because these class as compare instructions). Can some of that be re-used here?
The alternative might be to scan backward through instructions in the main loop, keeping a track of which parts of NZCV are "alive" as we go, so we always have that info available.
================
Comment at: llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp:308
+ "Instruction must only implicit define NZCV");
+ Register NZCV = MI.implicit_operands().begin()->getReg();
+ for (MachineBasicBlock::iterator Iter = std::next(MI.getIterator()),
----------------
Will this always be AArch64::NZCV?
================
Comment at: llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp:343
+ // Instruction defined NZCV so we can stop scanning
+ if (WritesNZCV)
+ break;
----------------
We can stop scanning as soon as the NZCV operand is marked as Dead too, I think.
================
Comment at: llvm/lib/Target/AArch64/AArch64MIPeepholeOpt.cpp:346
+ }
+ return true;
+}
----------------
On rare occasion the NZCV might be live-out of the block (which is probably enough reason to just return false, as opposed to trying to scan further blocks).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118663/new/
https://reviews.llvm.org/D118663
More information about the llvm-commits
mailing list