[llvm] 532356e - [Attributor] Merge ranges by expansion, avoid unknown ranges
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 16:53:57 PDT 2023
Author: Johannes Doerfert
Date: 2023-06-05T16:53:46-07:00
New Revision: 532356e82d9be75f969c97a76a8e7348ad05bc27
URL: https://github.com/llvm/llvm-project/commit/532356e82d9be75f969c97a76a8e7348ad05bc27
DIFF: https://github.com/llvm/llvm-project/commit/532356e82d9be75f969c97a76a8e7348ad05bc27.diff
LOG: [Attributor] Merge ranges by expansion, avoid unknown ranges
Different offsets can be handled by expansion rather than defaulting to
an unknown offset. Thus, [4,4] & [8,8] will result in [4, 12] rather
than [unknown, unknown].
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/test/Transforms/Attributor/value-simplify-pointer-info-vec.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index a70debdcf07a2..4aec1f51b6323 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -266,18 +266,24 @@ struct RangeTy {
}
RangeTy &operator&=(const RangeTy &R) {
- if (Offset == Unassigned)
- Offset = R.Offset;
- else if (R.Offset != Unassigned && R.Offset != Offset)
+ if (R.isUnassigned())
+ return *this;
+ if (isUnassigned())
+ return *this = R;
+ if (Offset == Unknown || R.Offset == Unknown)
Offset = Unknown;
-
- if (Size == Unassigned)
- Size = R.Size;
- else if (Size == Unknown || R.Size == Unknown)
+ if (Size == Unknown || R.Size == Unknown)
Size = Unknown;
- else if (R.Size != Unassigned)
+ if (offsetAndSizeAreUnknown())
+ return *this;
+ if (Offset == Unknown) {
Size = std::max(Size, R.Size);
-
+ } else if (Size == Unknown) {
+ Offset = std::min(Offset, R.Offset);
+ } else {
+ Offset = std::min(Offset, R.Offset);
+ Size = std::max(Offset + Size, R.Offset + R.Size) - Offset;
+ }
return *this;
}
diff --git a/llvm/test/Transforms/Attributor/value-simplify-pointer-info-vec.ll b/llvm/test/Transforms/Attributor/value-simplify-pointer-info-vec.ll
index f05a6f5028fbb..ff9184ef018ae 100644
--- a/llvm/test/Transforms/Attributor/value-simplify-pointer-info-vec.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify-pointer-info-vec.ll
@@ -64,7 +64,6 @@ define i32 @vec_write_3() {
; CHECK-NEXT: [[G:%.*]] = getelementptr i32, ptr [[A]], i64 1
; CHECK-NEXT: store <2 x i32> <i32 5, i32 5>, ptr [[G]], align 8
; CHECK-NEXT: [[J:%.*]] = getelementptr i32, ptr [[G]], i64 1
-; CHECK-NEXT: store <2 x i32> <i32 7, i32 7>, ptr [[J]], align 8
; CHECK-NEXT: [[L2B:%.*]] = load i32, ptr [[G]], align 8
; CHECK-NEXT: [[ADD:%.*]] = add i32 3, [[L2B]]
; CHECK-NEXT: ret i32 [[ADD]]
@@ -104,8 +103,6 @@ define i32 @vec_write_5(i32 %arg) {
; CHECK-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
; CHECK-NEXT: [[A:%.*]] = alloca <4 x i32>, align 16
; CHECK-NEXT: store i32 [[ARG]], ptr [[A]], align 16
-; CHECK-NEXT: [[G:%.*]] = getelementptr i32, ptr [[A]], i64 1
-; CHECK-NEXT: store <2 x i32> <i32 5, i32 5>, ptr [[G]], align 8
; CHECK-NEXT: [[ADD1:%.*]] = add i32 [[ARG]], 5
; CHECK-NEXT: [[ADD2:%.*]] = add i32 5, [[ADD1]]
; CHECK-NEXT: ret i32 [[ADD2]]
More information about the llvm-commits
mailing list