Skip to content

Commit 84dcf3d

Browse files
authored
[SystemZ] Require D12 for i128 accesses in isLegalAddressingMode() (#79221)
Machines with vector support handle i128 in vector registers and therefore only have the small displacement available for memory accesses. Update isLegalAddressingMode() to reflect this.
1 parent 7b11c08 commit 84dcf3d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,8 @@ bool SystemZTargetLowering::isLegalAddressingMode(const DataLayout &DL,
10671067
if (!isInt<20>(AM.BaseOffs))
10681068
return false;
10691069

1070-
bool RequireD12 = Subtarget.hasVector() && Ty->isVectorTy();
1070+
bool RequireD12 =
1071+
Subtarget.hasVector() && (Ty->isVectorTy() || Ty->isIntegerTy(128));
10711072
AddressingMode SupportedAM(!RequireD12, true);
10721073
if (I != nullptr)
10731074
SupportedAM = supportedAddressingMode(I, Subtarget.hasVector());

llvm/test/CodeGen/SystemZ/loop-01.ll

+23
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,26 @@ for.inc.i: ; preds = %for.body.i63
312312
%indvars.iv.next156.i.3 = add nsw i64 %indvars.iv155.i, 4
313313
br label %for.body.i63
314314
}
315+
316+
; Test that offsets are in range for i128 memory accesses.
317+
define void @fun10() {
318+
; CHECK-Z13-LABEL: fun10:
319+
; CHECK-Z13: # =>This Inner Loop Header: Depth=1
320+
; CHECK-Z13-NOT: lay
321+
entry:
322+
%A1 = alloca [3 x [7 x [10 x i128]]], align 8
323+
br label %for.body
324+
325+
for.body: ; preds = %for.body, %entry
326+
%IV = phi i64 [ 0, %entry ], [ %IV.next, %for.body ]
327+
%Addr1 = getelementptr inbounds [3 x [7 x [10 x i128]]], ptr %A1, i64 0, i64 %IV, i64 6, i64 6
328+
store i128 17174966165894859678, ptr %Addr1, align 8
329+
%Addr2 = getelementptr inbounds [3 x [7 x [10 x i128]]], ptr %A1, i64 0, i64 %IV, i64 6, i64 8
330+
store i128 17174966165894859678, ptr %Addr2, align 8
331+
%IV.next = add nuw nsw i64 %IV, 1
332+
%exitcond.not.i.i = icmp eq i64 %IV.next, 3
333+
br i1 %exitcond.not.i.i, label %exit, label %for.body
334+
335+
exit: ; preds = %for.body
336+
unreachable
337+
}

0 commit comments

Comments
 (0)