Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 9f34dc1

Browse files
author
Krzysztof Parzyszek
committed
[Hexagon] Specify vector alignment in DataLayout string
The DataLayout can calculate alignment of vectors based on the alignment of the element type and the number of elements. In fact, it is the product of these two values. The problem is that for vectors of N x i1, this will return the alignment of N bytes, since the alignment of i1 is 8 bits. The vector types of vNi1 should be aligned to N bits instead. Provide explicit alignment for HVX vectors to avoid such complications. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260678 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent ed899de commit 9f34dc1

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

lib/Target/Hexagon/HexagonTargetMachine.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ namespace llvm {
121121
FunctionPass *createHexagonStoreWidening();
122122
} // end namespace llvm;
123123

124-
/// HexagonTargetMachine ctor - Create an ILP32 architecture model.
125-
///
126124

127-
/// Hexagon_TODO: Do I need an aggregate alignment?
128-
///
129125
HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT,
130126
StringRef CPU, StringRef FS,
131127
const TargetOptions &Options,
132128
Reloc::Model RM, CodeModel::Model CM,
133129
CodeGenOpt::Level OL)
134-
: LLVMTargetMachine(T, "e-m:e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-"
135-
"i1:8:8-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a:0-"
136-
"n16:32", TT, CPU, FS, Options, RM, CM, OL),
130+
// Specify the vector alignment explicitly. For v512x1, the calculated
131+
// alignment would be 512*alignment(i1), which is 512 bytes, instead of
132+
// the required minimum of 64 bytes.
133+
: LLVMTargetMachine(T, "e-m:e-p:32:32:32-a:0-n16:32-"
134+
"i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
135+
"v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048",
136+
TT, CPU, FS, Options, RM, CM, OL),
137137
TLOF(make_unique<HexagonTargetObjectFile>()) {
138138
initAsmInfo();
139139
}

test/CodeGen/Hexagon/vector-align.ll

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
; RUN: llc -march=hexagon -mcpu=hexagonv60 -enable-hexagon-hvx < %s \
2+
; RUN: | FileCheck %s
3+
4+
; Check that the store to Q6VecPredResult does not get expanded into multiple
5+
; stores. There should be no memd's. This relies on the alignment specified
6+
; in the data layout string, so don't provide one here to make sure that the
7+
; default one from HexagonTargetMachine is correct.
8+
9+
; CHECK-NOT: memd
10+
11+
12+
@Q6VecPredResult = common global <16 x i32> zeroinitializer, align 64
13+
14+
; Function Attrs: nounwind
15+
define i32 @foo() #0 {
16+
entry:
17+
%0 = tail call <16 x i32> @llvm.hexagon.V6.lvsplatw(i32 1)
18+
%1 = tail call <512 x i1> @llvm.hexagon.V6.vandvrt(<16 x i32> %0, i32 -2147483648)
19+
store <512 x i1> %1, <512 x i1>* bitcast (<16 x i32>* @Q6VecPredResult to <512 x i1>*), align 64, !tbaa !1
20+
tail call void @print_vecpred(i32 64, i8* bitcast (<16 x i32>* @Q6VecPredResult to i8*)) #3
21+
ret i32 0
22+
}
23+
24+
; Function Attrs: nounwind readnone
25+
declare <512 x i1> @llvm.hexagon.V6.vandvrt(<16 x i32>, i32) #1
26+
27+
; Function Attrs: nounwind readnone
28+
declare <16 x i32> @llvm.hexagon.V6.lvsplatw(i32) #1
29+
30+
declare void @print_vecpred(i32, i8*) #2
31+
32+
attributes #0 = { nounwind "target-cpu"="hexagonv60" "target-features"="+hvx" }
33+
attributes #1 = { nounwind readnone }
34+
attributes #2 = { nounwind }
35+
36+
!1 = !{!2, !2, i64 0}
37+
!2 = !{!"omnipotent char", !3, i64 0}
38+
!3 = !{!"Simple C/C++ TBAA"}

0 commit comments

Comments
 (0)