[llvm] Apply the `AdjustICmpImmAndPred` optimization when it results in a one-instruction immediate materialization over a two-instruction materialization. (PR #83218)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 03:53:28 PST 2024
================
@@ -658,9 +659,12 @@ tryAdjustICmpImmAndPred(Register RHS, CmpInst::Predicate P,
// predicate if it is.
if (Size == 32)
C = static_cast<uint32_t>(C);
- if (!isLegalArithImmed(C))
- return std::nullopt;
- return {{C, P}};
+ if (isLegalArithImmed(C))
+ return {{C, P}};
+ if (AArch64_AM::isLogicalImmediate(C, Size) &&
+ !AArch64_AM::isLogicalImmediate(OriginalC, Size))
----------------
davemgreen wrote:
It would be a bit more code, but could this all use `AArch64_IMM::expandMOVImm(Imm, BitSize, Insn); Insn.size() == 1`? I believe that is what this is trying to achieve, and it would be more general to capture all the different ways for the immediate to be a single instruction.
https://github.com/llvm/llvm-project/pull/83218
More information about the llvm-commits
mailing list