Skip to content

Commit 5abd240

Browse files
committed
Generalize the instructions-to-materialize-immediate check.
1 parent 969bf72 commit 5abd240

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

llvm/lib/Target/AArch64/GISel/AArch64PostLegalizerLowering.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
///
2020
//===----------------------------------------------------------------------===//
2121

22+
#include "AArch64ExpandImm.h"
2223
#include "AArch64GlobalISelUtils.h"
2324
#include "AArch64PerfectShuffle.h"
2425
#include "AArch64Subtarget.h"
@@ -636,9 +637,17 @@ tryAdjustICmpImmAndPred(Register RHS, CmpInst::Predicate P,
636637
C = static_cast<uint32_t>(C);
637638
if (isLegalArithImmed(C))
638639
return {{C, P}};
639-
if (AArch64_AM::isLogicalImmediate(C, Size) &&
640-
!AArch64_AM::isLogicalImmediate(OriginalC, Size))
640+
641+
auto IsMaterializableInSingleInstruction = [=](uint64_t Imm) {
642+
SmallVector<AArch64_IMM::ImmInsnModel> Insn;
643+
AArch64_IMM::expandMOVImm(Imm, 32, Insn);
644+
return Insn.size() == 1;
645+
};
646+
647+
if (!IsMaterializableInSingleInstruction(OriginalC) &&
648+
IsMaterializableInSingleInstruction(C))
641649
return {{C, P}};
650+
642651
return std::nullopt;
643652
}
644653

0 commit comments

Comments
 (0)