Skip to content

Commit e78a5eb

Browse files
committed
[ConstantFolding] Canonicalize constexpr GEPs to i8
This patch canonicalizes constant expression GEPs to use i8 source element type, aka ptradd. This is the ConstantFolding equivalent of the InstCombine canonicalization introduced in #68882. I believe all our optimizations working on constant expression GEPs (like GlobalOpt etc) have already been switched to work on offsets, so I don't expect any significant fallout from this change. This is part of: https://discourse.llvm.org/t/rfc-replacing-getelementptr-with-ptradd/68699
1 parent ba702aa commit e78a5eb

File tree

96 files changed

+566
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+566
-590
lines changed

clang/test/CodeGen/RISCV/riscv-inline-asm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ extern int var, arr[2][2];
4949
struct Pair { int a, b; } pair;
5050

5151
// CHECK-LABEL: test_s(
52-
// CHECK: call void asm sideeffect "// $0 $1 $2", "s,s,s"(ptr nonnull @var, ptr nonnull getelementptr inbounds ([2 x [2 x i32]], ptr @arr, {{.*}}), ptr nonnull @test_s)
53-
// CHECK: call void asm sideeffect "// $0", "s"(ptr nonnull getelementptr inbounds (%struct.Pair, ptr @pair, {{.*}}))
54-
// CHECK: call void asm sideeffect "// $0 $1 $2", "S,S,S"(ptr nonnull @var, ptr nonnull getelementptr inbounds ([2 x [2 x i32]], ptr @arr, {{.*}}), ptr nonnull @test_s)
52+
// CHECK: call void asm sideeffect "// $0 $1 $2", "s,s,s"(ptr nonnull @var, ptr nonnull getelementptr inbounds (i8, ptr @arr, {{.*}}), ptr nonnull @test_s)
53+
// CHECK: call void asm sideeffect "// $0", "s"(ptr nonnull getelementptr inbounds (i8, ptr @pair, {{.*}}))
54+
// CHECK: call void asm sideeffect "// $0 $1 $2", "S,S,S"(ptr nonnull @var, ptr nonnull getelementptr inbounds (i8, ptr @arr, {{.*}}), ptr nonnull @test_s)
5555
void test_s(void) {
5656
asm("// %0 %1 %2" :: "s"(&var), "s"(&arr[1][1]), "s"(test_s));
5757
asm("// %0" :: "s"(&pair.b));

clang/test/CodeGen/attr-counted-by.c

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

clang/test/CodeGenCXX/atomicinit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace PR18097 {
8686
};
8787
// CHECK-LABEL: define {{.*}} @__cxx_global_var_init
8888
// CHECK: call void @_ZN7PR180977dynamic1XC1Ei(ptr {{[^,]*}} @_ZN7PR180977dynamic1yE, i32 noundef 4)
89-
// CHECK: store i32 5, ptr getelementptr inbounds ({{.*}}, ptr @_ZN7PR180977dynamic1yE, i32 0, i32 1)
89+
// CHECK: store i32 5, ptr getelementptr inbounds (i8, ptr @_ZN7PR180977dynamic1yE, i32 4)
9090
Y y = { X(4), 5 };
9191
}
9292

@@ -110,7 +110,7 @@ namespace PR18097 {
110110
// CHECK-LABEL: define {{.*}} @__cxx_global_var_init
111111
// CHECK: tail call void @llvm.memcpy.p0.p0.i32(ptr{{.*}} @_ZN7PR180978constant2y2E, ptr{{.*}} @_ZN7PR180978constantL1xE, i32 3, i1 false)
112112
// CHECK: %0 = load i32, ptr @_ZN7PR180978constant1zE
113-
// CHECK: store i32 %0, ptr getelementptr inbounds (%"struct.PR18097::constant::Y", ptr @_ZN7PR180978constant2y2E, i32 0, i32 1)
113+
// CHECK: store i32 %0, ptr getelementptr inbounds (i8, ptr @_ZN7PR180978constant2y2E, i32 4)
114114
int z;
115115
constexpr X x{1};
116116
Y y2 = { x, z };

clang/test/CodeGenCXX/auto-var-init.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ TEST_UNINIT(base, base);
13461346
// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_base_uninit.uninit{{.+}}), !annotation [[AUTO_INIT]]
13471347
// ZERO-LABEL: @test_base_uninit()
13481348
// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,{{.+}}), !annotation [[AUTO_INIT]]
1349-
// ZERO-O1: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV4base, i64 0, i32 0, i64 2), {{.*}}, align 8
1349+
// ZERO-O1: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV4base, i64 16), {{.*}}, align 8
13501350
// ZERO-O1-NOT: !annotation
13511351

13521352
TEST_BRACES(base, base);
@@ -1367,7 +1367,7 @@ TEST_UNINIT(derived, derived);
13671367
// ZERO-LABEL: @test_derived_uninit()
13681368
// ZERO-O0: call void @llvm.memset{{.*}}, i8 0, {{.+}}), !annotation [[AUTO_INIT]]
13691369
// ZERO-O1: store i64 0, {{.*}} align 8, !annotation [[AUTO_INIT]]
1370-
// ZERO-O1: store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTV7derived, i64 0, i32 0, i64 2), {{.*}} align 8
1370+
// ZERO-O1: store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTV7derived, i64 16), {{.*}} align 8
13711371

13721372
TEST_BRACES(derived, derived);
13731373
// CHECK-LABEL: @test_derived_braces()

clang/test/Profile/c-unreachable-after-switch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// CHECK-LABEL: @foo()
66
// CHECK: store {{.*}} @[[C]]
77
void foo(void) {
8-
// CHECK: store {{.*}} @[[C]], i64 0, i64 2
8+
// CHECK: store {{.*}} @[[C]], i64 16)
99
switch (0) {
1010
default:
1111
return;
1212
}
1313
// We shouldn't emit the unreachable counter. This used to crash in GlobalDCE.
14-
// CHECK-NOT: store {{.*}} @[[C]], i64 0, i64 1}
14+
// CHECK-NOT: store {{.*}} @[[C]], i64 8)
1515
}

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,6 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
869869
bool InBounds = GEP->isInBounds();
870870

871871
Type *SrcElemTy = GEP->getSourceElementType();
872-
Type *ResElemTy = GEP->getResultElementType();
873872
Type *ResTy = GEP->getType();
874873
if (!SrcElemTy->isSized() || isa<ScalableVectorType>(SrcElemTy))
875874
return nullptr;
@@ -944,43 +943,18 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
944943
return ConstantExpr::getIntToPtr(C, ResTy);
945944
}
946945

947-
// Otherwise form a regular getelementptr. Recompute the indices so that
948-
// we eliminate over-indexing of the notional static type array bounds.
949-
// This makes it easy to determine if the getelementptr is "inbounds".
950-
951-
// For GEPs of GlobalValues, use the value type, otherwise use an i8 GEP.
952-
if (auto *GV = dyn_cast<GlobalValue>(Ptr))
953-
SrcElemTy = GV->getValueType();
954-
else
955-
SrcElemTy = Type::getInt8Ty(Ptr->getContext());
956-
957-
if (!SrcElemTy->isSized())
958-
return nullptr;
959-
960-
Type *ElemTy = SrcElemTy;
961-
SmallVector<APInt> Indices = DL.getGEPIndicesForOffset(ElemTy, Offset);
962-
if (Offset != 0)
963-
return nullptr;
964-
965-
// Try to add additional zero indices to reach the desired result element
966-
// type.
967-
// TODO: Should we avoid extra zero indices if ResElemTy can't be reached and
968-
// we'll have to insert a bitcast anyway?
969-
while (ElemTy != ResElemTy) {
970-
Type *NextTy = GetElementPtrInst::getTypeAtIndex(ElemTy, (uint64_t)0);
971-
if (!NextTy)
972-
break;
973-
974-
Indices.push_back(APInt::getZero(isa<StructType>(ElemTy) ? 32 : BitWidth));
975-
ElemTy = NextTy;
946+
// Try to infer inbounds for GEPs of globals.
947+
if (!InBounds && Offset.isNonNegative()) {
948+
bool CanBeNull, CanBeFreed;
949+
uint64_t DerefBytes =
950+
Ptr->getPointerDereferenceableBytes(DL, CanBeNull, CanBeFreed);
951+
InBounds = DerefBytes != 0 && !CanBeNull && Offset.sle(DerefBytes);
976952
}
977953

978-
SmallVector<Constant *, 32> NewIdxs;
979-
for (const APInt &Index : Indices)
980-
NewIdxs.push_back(ConstantInt::get(
981-
Type::getIntNTy(Ptr->getContext(), Index.getBitWidth()), Index));
982-
983-
return ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs, InBounds,
954+
// Otherwise canonicalize this to a single ptradd.
955+
LLVMContext &Ctx = Ptr->getContext();
956+
return ConstantExpr::getGetElementPtr(Type::getInt8Ty(Ctx), Ptr,
957+
ConstantInt::get(Ctx, Offset), InBounds,
984958
InRange);
985959
}
986960

llvm/test/Other/constant-fold-gep.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@
106106

107107
; PLAIN: @Y = global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 2)
108108
; PLAIN: @Z = global ptr getelementptr inbounds (i32, ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 0), i64 1)
109-
; OPT: @Y = local_unnamed_addr global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 2)
110-
; OPT: @Z = local_unnamed_addr global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 1)
111-
; TO: @Y = local_unnamed_addr global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 2)
112-
; TO: @Z = local_unnamed_addr global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 1)
109+
; OPT: @Y = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 48)
110+
; OPT: @Z = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 12)
111+
; TO: @Y = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 48)
112+
; TO: @Z = local_unnamed_addr global ptr getelementptr inbounds (i8, ptr @ext, i64 12)
113113

114114
@ext = external global [3 x { i32, i32 }]
115115
@Y = global ptr getelementptr inbounds ([3 x { i32, i32 }], ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 1), i64 1)
@@ -433,10 +433,10 @@ define ptr @fO() nounwind {
433433
; PLAIN: ret ptr %t
434434
; PLAIN: }
435435
; OPT: define ptr @fZ() local_unnamed_addr #0 {
436-
; OPT: ret ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 1)
436+
; OPT: ret ptr getelementptr inbounds (i8, ptr @ext, i64 12)
437437
; OPT: }
438438
; TO: define ptr @fZ() local_unnamed_addr #0 {
439-
; TO: ret ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 1)
439+
; TO: ret ptr getelementptr inbounds (i8, ptr @ext, i64 12)
440440
; TO: }
441441
; SCEV: Classifying expressions for: @fZ
442442
; SCEV: %t = bitcast ptr getelementptr inbounds (i32, ptr getelementptr inbounds ([3 x { i32, i32 }], ptr @ext, i64 0, i64 1, i32 0), i64 1) to ptr
@@ -464,7 +464,7 @@ define ptr @same_addrspace() nounwind noinline {
464464
; OPT: same_addrspace
465465
%p = getelementptr inbounds i8, ptr @p0, i32 2
466466
ret ptr %p
467-
; OPT: ret ptr getelementptr inbounds ([4 x i8], ptr @p0, i64 0, i64 2)
467+
; OPT: ret ptr getelementptr inbounds (i8, ptr @p0, i64 2)
468468
}
469469

470470
@gv1 = internal global i32 1

llvm/test/Other/optimize-inrange-gep.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ define void @foo(ptr %p) {
2020
;
2121
; CHECK-LABEL: define void @foo(
2222
; CHECK-SAME: ptr nocapture writeonly [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
23-
; CHECK-NEXT: store ptr getelementptr inbounds inrange(-24, 0) ({ [3 x ptr] }, ptr @vtable, i64 1, i32 0, i64 0), ptr [[P]], align 8
23+
; CHECK-NEXT: store ptr getelementptr inbounds inrange(-24, 0) (i8, ptr @vtable, i64 24), ptr [[P]], align 8
2424
; CHECK-NEXT: ret void
2525
;
2626
store ptr getelementptr inrange(-24, 0) ({ [3 x ptr], [3 x ptr] }, ptr @vtable, i32 0, i32 0, i32 3), ptr %p

llvm/test/Transforms/FunctionSpecialization/function-specialization-constant-expression.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ define internal i64 @zoo(i1 %flag) {
3030
; CHECK-NEXT: entry:
3131
; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[PLUS:%.*]], label [[MINUS:%.*]]
3232
; CHECK: plus:
33-
; CHECK-NEXT: [[TMP0:%.*]] = call i64 @func2.specialized.2(ptr getelementptr inbounds ([[STRUCT:%.*]], ptr @Global, i64 0, i32 3))
33+
; CHECK-NEXT: [[TMP0:%.*]] = call i64 @func2.specialized.2(ptr getelementptr inbounds (i8, ptr @Global, i64 8))
3434
; CHECK-NEXT: br label [[MERGE:%.*]]
3535
; CHECK: minus:
36-
; CHECK-NEXT: [[TMP1:%.*]] = call i64 @func2.specialized.1(ptr getelementptr inbounds ([[STRUCT]], ptr @Global, i64 0, i32 4))
36+
; CHECK-NEXT: [[TMP1:%.*]] = call i64 @func2.specialized.1(ptr getelementptr inbounds (i8, ptr @Global, i64 16))
3737
; CHECK-NEXT: br label [[MERGE]]
3838
; CHECK: merge:
39-
; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ ptrtoint (ptr getelementptr inbounds ([[STRUCT]], ptr @Global, i64 0, i32 3) to i64), [[PLUS]] ], [ ptrtoint (ptr getelementptr inbounds ([[STRUCT]], ptr @Global, i64 0, i32 4) to i64), [[MINUS]] ]
39+
; CHECK-NEXT: [[TMP2:%.*]] = phi i64 [ ptrtoint (ptr getelementptr inbounds (i8, ptr @Global, i64 8) to i64), [[PLUS]] ], [ ptrtoint (ptr getelementptr inbounds (i8, ptr @Global, i64 16) to i64), [[MINUS]] ]
4040
; CHECK-NEXT: ret i64 [[TMP2]]
4141
;
4242
entry:

llvm/test/Transforms/GVN/PRE/load-pre-licm.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target triple = "i386-apple-darwin11.0.0"
88
define void @Bubble() nounwind noinline {
99
; CHECK-LABEL: @Bubble(
1010
; CHECK-NEXT: entry:
11-
; CHECK-NEXT: [[TMP7_PRE:%.*]] = load i32, ptr getelementptr inbounds ([5001 x i32], ptr @sortlist, i32 0, i32 1), align 4
11+
; CHECK-NEXT: [[TMP7_PRE:%.*]] = load i32, ptr getelementptr inbounds (i8, ptr @sortlist, i32 4), align 4
1212
; CHECK-NEXT: br label [[WHILE_BODY5:%.*]]
1313
; CHECK: while.body5:
1414
; CHECK-NEXT: [[TMP7:%.*]] = phi i32 [ [[TMP7_PRE]], [[ENTRY:%.*]] ], [ [[TMP71:%.*]], [[IF_END:%.*]] ]

llvm/test/Transforms/GVN/PRE/phi-translate-2.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ define void @test2(i64 %i) {
6363
; CHECK: if.then:
6464
; CHECK-NEXT: [[CALL:%.*]] = tail call i64 (...) @goo()
6565
; CHECK-NEXT: store i64 [[CALL]], ptr @g2, align 8
66-
; CHECK-NEXT: [[T2_PRE:%.*]] = load i64, ptr getelementptr inbounds ([100 x i64], ptr @a, i64 0, i64 3), align 8
67-
; CHECK-NEXT: [[T3_PRE:%.*]] = load i64, ptr getelementptr inbounds ([100 x i64], ptr @b, i64 0, i64 3), align 8
66+
; CHECK-NEXT: [[T2_PRE:%.*]] = load i64, ptr getelementptr inbounds (i8, ptr @a, i64 24), align 8
67+
; CHECK-NEXT: [[T3_PRE:%.*]] = load i64, ptr getelementptr inbounds (i8, ptr @b, i64 24), align 8
6868
; CHECK-NEXT: [[DOTPRE:%.*]] = mul nsw i64 [[T3_PRE]], [[T2_PRE]]
6969
; CHECK-NEXT: br label [[IF_END]]
7070
; CHECK: if.end:

llvm/test/Transforms/IndVarSimplify/D108043.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ define internal fastcc void @func_2() unnamed_addr {
99
; CHECK-NEXT: lbl_2898.preheader:
1010
; CHECK-NEXT: br label [[LBL_2898:%.*]]
1111
; CHECK: lbl_2898.loopexit:
12-
; CHECK-NEXT: store ptr getelementptr inbounds ([4 x [6 x i32]], ptr @g_2168, i64 0, i64 3, i64 1), ptr @g_1150, align 8
12+
; CHECK-NEXT: store ptr getelementptr inbounds (i8, ptr @g_2168, i64 76), ptr @g_1150, align 8
1313
; CHECK-NEXT: br label [[LBL_2898]]
1414
; CHECK: lbl_2898:
1515
; CHECK-NEXT: br label [[FOR_COND884:%.*]]

llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define void @foo() {
1414
; CHECK-NEXT: bb:
1515
; CHECK-NEXT: br label [[BB3:%.*]]
1616
; CHECK: bb3:
17-
; CHECK-NEXT: [[TMP6:%.*]] = load i8, ptr getelementptr inbounds ([0 x i8], ptr @global, i64 0, i64 1), align 1
17+
; CHECK-NEXT: [[TMP6:%.*]] = load i8, ptr getelementptr inbounds (i8, ptr @global, i64 1), align 1
1818
; CHECK-NEXT: br i1 false, label [[BB7:%.*]], label [[BB11:%.*]]
1919
; CHECK: bb7:
2020
; CHECK-NEXT: [[TMP8:%.*]] = zext i8 [[TMP6]] to i64

llvm/test/Transforms/IndVarSimplify/floating-point-small-iv.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ define void @uitofp_fptoui_range_with_negative() {
357357
; CHECK-NEXT: entry:
358358
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
359359
; CHECK: for.body:
360-
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds ([16777219 x i32], ptr @array, i64 0, i64 100), align 4
360+
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds (i8, ptr @array, i64 400), align 4
361361
; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[CLEANUP:%.*]]
362362
; CHECK: cleanup:
363363
; CHECK-NEXT: ret void
@@ -418,7 +418,7 @@ define void @uitofp_fptosi_range_with_negative () {
418418
; CHECK-NEXT: entry:
419419
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
420420
; CHECK: for.body:
421-
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds ([16777219 x i32], ptr @array, i64 0, i64 100), align 4
421+
; CHECK-NEXT: store i32 100, ptr getelementptr inbounds (i8, ptr @array, i64 400), align 4
422422
; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[CLEANUP:%.*]]
423423
; CHECK: cleanup:
424424
; CHECK-NEXT: ret void

llvm/test/Transforms/IndVarSimplify/lftr-dead-ivs.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ define void @dom_store_preinc() #0 {
112112
; CHECK-NEXT: [[P_0:%.*]] = phi ptr [ @data, [[ENTRY:%.*]] ], [ [[TMP3:%.*]], [[LOOP]] ]
113113
; CHECK-NEXT: store volatile i8 0, ptr [[P_0]], align 1
114114
; CHECK-NEXT: [[TMP3]] = getelementptr inbounds i8, ptr [[P_0]], i64 1
115-
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[P_0]], getelementptr ([240 x i8], ptr @data, i64 1, i64 5)
115+
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[P_0]], getelementptr (i8, ptr @data, i64 245)
116116
; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
117117
; CHECK: exit:
118118
; CHECK-NEXT: ret void
@@ -141,7 +141,7 @@ define void @dom_store_postinc() #0 {
141141
; CHECK-NEXT: [[P_0:%.*]] = phi ptr [ @data, [[ENTRY:%.*]] ], [ [[TMP3:%.*]], [[LOOP]] ]
142142
; CHECK-NEXT: [[TMP3]] = getelementptr inbounds i8, ptr [[P_0]], i64 1
143143
; CHECK-NEXT: store volatile i8 0, ptr [[TMP3]], align 1
144-
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[TMP3]], getelementptr ([240 x i8], ptr @data, i64 1, i64 6)
144+
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[TMP3]], getelementptr (i8, ptr @data, i64 246)
145145
; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
146146
; CHECK: exit:
147147
; CHECK-NEXT: ret void
@@ -170,7 +170,7 @@ define i8 @dom_load() #0 {
170170
; CHECK-NEXT: [[P_0:%.*]] = phi ptr [ @data, [[ENTRY:%.*]] ], [ [[TMP3:%.*]], [[LOOP]] ]
171171
; CHECK-NEXT: [[TMP3]] = getelementptr inbounds i8, ptr [[P_0]], i64 1
172172
; CHECK-NEXT: [[V:%.*]] = load i8, ptr [[TMP3]], align 1
173-
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[TMP3]], getelementptr ([240 x i8], ptr @data, i64 1, i64 6)
173+
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[TMP3]], getelementptr (i8, ptr @data, i64 246)
174174
; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
175175
; CHECK: exit:
176176
; CHECK-NEXT: [[V_LCSSA:%.*]] = phi i8 [ [[V]], [[LOOP]] ]

llvm/test/Transforms/IndVarSimplify/lftr.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ define void @test_zext(ptr %a) #0 {
196196
; CHECK-NEXT: [[T2:%.*]] = load i8, ptr [[DOT0]], align 1
197197
; CHECK-NEXT: [[T3]] = getelementptr inbounds i8, ptr [[P_0]], i64 1
198198
; CHECK-NEXT: store i8 [[T2]], ptr [[P_0]], align 1
199-
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[P_0]], getelementptr inbounds ([240 x i8], ptr @data, i64 0, i64 239)
199+
; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne ptr [[P_0]], getelementptr inbounds (i8, ptr @data, i64 239)
200200
; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]]
201201
; CHECK: exit:
202202
; CHECK-NEXT: ret void

llvm/test/Transforms/InstCombine/addrspacecast.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ define i32 @memcpy_addrspacecast() nounwind {
141141
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[LOOP_BODY]] ]
142142
; CHECK-NEXT: [[SUM:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[SUM_INC:%.*]], [[LOOP_BODY]] ]
143143
; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[I]] to i16
144-
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i8, ptr addrspace(2) getelementptr inbounds ([60 x i8], ptr addrspace(2) @const_array, i16 0, i16 4), i16 [[TMP0]]
144+
; CHECK-NEXT: [[PTR:%.*]] = getelementptr i8, ptr addrspace(2) getelementptr inbounds (i8, ptr addrspace(2) @const_array, i16 4), i16 [[TMP0]]
145145
; CHECK-NEXT: [[LOAD:%.*]] = load i8, ptr addrspace(2) [[PTR]], align 1
146146
; CHECK-NEXT: [[EXT:%.*]] = zext i8 [[LOAD]] to i32
147147
; CHECK-NEXT: [[SUM_INC]] = add i32 [[SUM]], [[EXT]]

llvm/test/Transforms/InstCombine/align-addr.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ define <16 x i8> @test1_as1(<2 x i64> %x) {
8181

8282
define <16 x i8> @test1_as1_gep(<2 x i64> %x) {
8383
; CHECK-LABEL: @test1_as1_gep(
84-
; CHECK-NEXT: [[TMP:%.*]] = load <16 x i8>, ptr addrspace(1) getelementptr inbounds ([8 x i32], ptr addrspace(1) @GLOBAL_as1_gep, i32 0, i32 4), align 1
84+
; CHECK-NEXT: [[TMP:%.*]] = load <16 x i8>, ptr addrspace(1) getelementptr inbounds (i8, ptr addrspace(1) @GLOBAL_as1_gep, i32 16), align 1
8585
; CHECK-NEXT: ret <16 x i8> [[TMP]]
8686
;
8787
%tmp = load <16 x i8>, ptr addrspace(1) getelementptr ([8 x i32], ptr addrspace(1) @GLOBAL_as1_gep, i16 0, i16 4), align 1

llvm/test/Transforms/InstCombine/binop-select-cast-of-select-cond.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ define i64 @pr64669(i64 %a) {
232232
; CHECK-LABEL: define i64 @pr64669
233233
; CHECK-SAME: (i64 [[A:%.*]]) {
234234
; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[A]], 1
235-
; CHECK-NEXT: [[ADD:%.*]] = select i1 icmp ne (ptr getelementptr inbounds ([72 x i32], ptr @b, i64 0, i64 25), ptr @c), i64 [[TMP1]], i64 0
235+
; CHECK-NEXT: [[ADD:%.*]] = select i1 icmp ne (ptr getelementptr inbounds (i8, ptr @b, i64 100), ptr @c), i64 [[TMP1]], i64 0
236236
; CHECK-NEXT: ret i64 [[ADD]]
237237
;
238238
%mul = select i1 icmp ne (ptr getelementptr inbounds ([72 x i32], ptr @b, i64 0, i64 25), ptr @c), i64 %a, i64 0

llvm/test/Transforms/InstCombine/constant-fold-address-space-pointer.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ define i32 @test_cast_gep_large_indices_as() {
223223

224224
define i32 @test_constant_cast_gep_struct_indices_as() {
225225
; CHECK-LABEL: @test_constant_cast_gep_struct_indices_as(
226-
; CHECK-NEXT: [[Y:%.*]] = load i32, ptr addrspace(3) getelementptr inbounds ([[STRUCT_FOO:%.*]], ptr addrspace(3) @constant_fold_global_ptr, i16 0, i32 2, i16 2), align 4
226+
; CHECK-NEXT: [[Y:%.*]] = load i32, ptr addrspace(3) getelementptr inbounds (i8, ptr addrspace(3) @constant_fold_global_ptr, i16 16), align 4
227227
; CHECK-NEXT: ret i32 [[Y]]
228228
;
229229
%x = getelementptr %struct.foo, ptr addrspace(3) @constant_fold_global_ptr, i18 0, i32 2, i12 2

0 commit comments

Comments
 (0)