|
19 | 19 | ///
|
20 | 20 | //===----------------------------------------------------------------------===//
|
21 | 21 |
|
| 22 | +#include "AArch64ExpandImm.h" |
22 | 23 | #include "AArch64GlobalISelUtils.h"
|
23 | 24 | #include "AArch64PerfectShuffle.h"
|
24 | 25 | #include "AArch64Subtarget.h"
|
@@ -563,7 +564,8 @@ tryAdjustICmpImmAndPred(Register RHS, CmpInst::Predicate P,
|
563 | 564 | auto ValAndVReg = getIConstantVRegValWithLookThrough(RHS, MRI);
|
564 | 565 | if (!ValAndVReg)
|
565 | 566 | return std::nullopt;
|
566 |
| - uint64_t C = ValAndVReg->Value.getZExtValue(); |
| 567 | + uint64_t OriginalC = ValAndVReg->Value.getZExtValue(); |
| 568 | + uint64_t C = OriginalC; |
567 | 569 | if (isLegalArithImmed(C))
|
568 | 570 | return std::nullopt;
|
569 | 571 |
|
@@ -633,9 +635,20 @@ tryAdjustICmpImmAndPred(Register RHS, CmpInst::Predicate P,
|
633 | 635 | // predicate if it is.
|
634 | 636 | if (Size == 32)
|
635 | 637 | C = static_cast<uint32_t>(C);
|
636 |
| - if (!isLegalArithImmed(C)) |
637 |
| - return std::nullopt; |
638 |
| - return {{C, P}}; |
| 638 | + if (isLegalArithImmed(C)) |
| 639 | + return {{C, P}}; |
| 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)) |
| 649 | + return {{C, P}}; |
| 650 | + |
| 651 | + return std::nullopt; |
639 | 652 | }
|
640 | 653 |
|
641 | 654 | /// Determine whether or not it is possible to update the RHS and predicate of
|
|
0 commit comments