summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorHaicheng Wu <haicheng@codeaurora.org>2016-12-07 01:45:04 +0000
committerHaicheng Wu <haicheng@codeaurora.org>2016-12-07 01:45:04 +0000
commitf8b834049ae0bf13de126c8ca7d2c9628fb9bec9 (patch)
treef76d8228abe7a45484e19dfd24ed2cd8b1377e50 /llvm
parent5205c35075c24ab6e946c91e171fb93fe6fba98c (diff)
downloadbcm5719-llvm-f8b834049ae0bf13de126c8ca7d2c9628fb9bec9.tar.gz
bcm5719-llvm-f8b834049ae0bf13de126c8ca7d2c9628fb9bec9.zip
[AArch64] Correct the check of signed 9-bit imm in isLegalAddressingMode()
In the addressing mode, signed 9-bit imm is [-256, 255], not [-512, 511]. Differential Revision: https://reviews.llvm.org/D27480 llvm-svn: 288876
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/AArch64/AArch64ISelLowering.cpp2
-rw-r--r--llvm/test/Analysis/CostModel/AArch64/gep.ll98
2 files changed, 98 insertions, 2 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 581958c3e0f..af3ab1b0fb3 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -7437,7 +7437,7 @@ bool AArch64TargetLowering::isLegalAddressingMode(const DataLayout &DL,
int64_t Offset = AM.BaseOffs;
// 9-bit signed offset
- if (Offset >= -(1LL << 9) && Offset <= (1LL << 9) - 1)
+ if (isInt<9>(Offset))
return true;
// 12-bit unsigned offset
diff --git a/llvm/test/Analysis/CostModel/AArch64/gep.ll b/llvm/test/Analysis/CostModel/AArch64/gep.ll
index 99284cb5b58..f3d83c13302 100644
--- a/llvm/test/Analysis/CostModel/AArch64/gep.ll
+++ b/llvm/test/Analysis/CostModel/AArch64/gep.ll
@@ -125,7 +125,7 @@ define i32 @test15(i32* %p, i32 %i) {
define i64 @test16(i64* %p, i32 %i) {
; CHECK-LABEL: test16
-; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i64, i64*
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
%a = getelementptr inbounds i64, i64* %p, i32 -64
%v = load i64, i64* %a
ret i64 %v
@@ -194,3 +194,99 @@ define i64 @test24(i64* %p, i32 %i) {
%v = load i64, i64* %a
ret i64 %v
}
+
+define i8 @test25(i8* %p, i32 %i) {
+; CHECK-LABEL: test25
+; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
+ %a = getelementptr inbounds i8, i8* %p, i32 -128
+ %v = load i8, i8* %a
+ ret i8 %v
+}
+
+define i16 @test26(i16* %p, i32 %i) {
+; CHECK-LABEL: test26
+; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
+ %a = getelementptr inbounds i16, i16* %p, i32 -128
+ %v = load i16, i16* %a
+ ret i16 %v
+}
+
+define i32 @test27(i32* %p, i32 %i) {
+; CHECK-LABEL: test27
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
+ %a = getelementptr inbounds i32, i32* %p, i32 -128
+ %v = load i32, i32* %a
+ ret i32 %v
+}
+
+define i64 @test28(i64* %p, i32 %i) {
+; CHECK-LABEL: test28
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
+ %a = getelementptr inbounds i64, i64* %p, i32 -128
+ %v = load i64, i64* %a
+ ret i64 %v
+}
+
+define i8 @test29(i8* %p, i32 %i) {
+; CHECK-LABEL: test29
+; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
+ %a = getelementptr inbounds i8, i8* %p, i32 -256
+ %v = load i8, i8* %a
+ ret i8 %v
+}
+
+define i16 @test30(i16* %p, i32 %i) {
+; CHECK-LABEL: test30
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i16, i16*
+ %a = getelementptr inbounds i16, i16* %p, i32 -256
+ %v = load i16, i16* %a
+ ret i16 %v
+}
+
+define i32 @test31(i32* %p, i32 %i) {
+; CHECK-LABEL: test31
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
+ %a = getelementptr inbounds i32, i32* %p, i32 -256
+ %v = load i32, i32* %a
+ ret i32 %v
+}
+
+define i64 @test32(i64* %p, i32 %i) {
+; CHECK-LABEL: test32
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
+ %a = getelementptr inbounds i64, i64* %p, i32 -256
+ %v = load i64, i64* %a
+ ret i64 %v
+}
+
+define i8 @test33(i8* %p, i32 %i) {
+; CHECK-LABEL: test33
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i8, i8*
+ %a = getelementptr inbounds i8, i8* %p, i32 -512
+ %v = load i8, i8* %a
+ ret i8 %v
+}
+
+define i16 @test34(i16* %p, i32 %i) {
+; CHECK-LABEL: test34
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i16, i16*
+ %a = getelementptr inbounds i16, i16* %p, i32 -512
+ %v = load i16, i16* %a
+ ret i16 %v
+}
+
+define i32 @test35(i32* %p, i32 %i) {
+; CHECK-LABEL: test35
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
+ %a = getelementptr inbounds i32, i32* %p, i32 -512
+ %v = load i32, i32* %a
+ ret i32 %v
+}
+
+define i64 @test36(i64* %p, i32 %i) {
+; CHECK-LABEL: test36
+; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
+ %a = getelementptr inbounds i64, i64* %p, i32 -512
+ %v = load i64, i64* %a
+ ret i64 %v
+}
OpenPOWER on IntegriCloud