File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -16561,8 +16561,22 @@ LLT AArch64TargetLowering::getOptimalMemOpLLT(
16561
16561
// 12-bit optionally shifted immediates are legal for adds.
16562
16562
bool AArch64TargetLowering::isLegalAddImmediate(int64_t Immed,
16563
16563
int64_t ScalableImm) const {
16564
- if (ScalableImm)
16565
- return false;
16564
+ if (ScalableImm) {
16565
+ // Scalable immediates require SVE support; mixed fixed + scalable
16566
+ // immediates are not supported by the current instructions.
16567
+ if (Immed || !Subtarget->hasSVE())
16568
+ return false;
16569
+
16570
+ // addvl's immediates are in terms of the number of bytes in a register.
16571
+ // Since there are 16 in the base supported size (128bits), we need to
16572
+ // divide the immediate by that much to give us a useful immediate to
16573
+ // multiply by vscale. We can't have a remainder as a result of this.
16574
+ if (ScalableImm % 16 != 0)
16575
+ return false;
16576
+ int64_t Imm = ScalableImm / 16;
16577
+
16578
+ return Imm >= -32 && Imm <= 31;
16579
+ }
16566
16580
16567
16581
if (Immed == std::numeric_limits<int64_t>::min()) {
16568
16582
LLVM_DEBUG(dbgs() << "Illegal add imm " << Immed
Original file line number Diff line number Diff line change @@ -31,15 +31,15 @@ const std::initializer_list<TestCase> Tests = {
31
31
32
32
// Scalable; addvl increments by whole registers, range [-32,31]
33
33
// +(16 * vscale), one register's worth
34
- {0 , 16 , false },
34
+ {0 , 16 , true },
35
35
// +(8 * vscale), half a register's worth
36
36
{0 , 8 , false },
37
37
// -(32 * 16 * vscale)
38
- {0 , -512 , false },
38
+ {0 , -512 , true },
39
39
// -(33 * 16 * vscale)
40
40
{0 , -528 , false },
41
41
// +(31 * 16 * vscale)
42
- {0 , 496 , false },
42
+ {0 , 496 , true },
43
43
// +(32 * 16 * vscale)
44
44
{0 , 512 , false },
45
45
You can’t perform that action at this time.
0 commit comments