Skip to content

Commit d10b765

Browse files
authored
[ConstantFold] Remove notional over-indexing fold (#93697)
The data-layout independent constant folding currently has some rather gnarly code for canonicalizing GEP indices to reduce "notional overindexing", and then infers inbounds based on that canonicalization. Now that we canonicalize to i8 GEPs, this canonicalization is essentially useless, as we'll discard it as soon as the GEP hits the data-layout aware constant folder anyway. As such, I'd like to remove this code entirely. This shouldn't have any impact on optimization capabilities.
1 parent 4bce270 commit d10b765

29 files changed

+58
-259
lines changed

clang/test/CodeGen/object-size.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void test2(void) {
3434

3535
// CHECK-LABEL: define{{.*}} void @test3
3636
void test3(void) {
37-
// CHECK: = call ptr @__strcpy_chk(ptr getelementptr inbounds ([63 x i8], ptr @gbuf, i64 1, i64 37), ptr @.str, i64 0)
37+
// CHECK: = call ptr @__strcpy_chk(ptr getelementptr inbounds ([63 x i8], ptr @gbuf, i64 0, i64 100), ptr @.str, i64 0)
3838
strcpy(&gbuf[100], "Hi there");
3939
}
4040

clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,21 @@ std::initializer_list<std::initializer_list<int>> nested = {
112112
// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested0_, i64 1)
113113
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested0_,
114114
// CHECK-DYNAMIC-BE: ptr @_ZGR6nested_, align 8
115-
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested0_, i64 1, i64 0),
115+
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested0_, i64 0, i64 2),
116116
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i32 0, i32 1), align 8
117117
// CHECK-DYNAMIC-BE: store i32 3, ptr @_ZGR6nested1_
118118
// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested1_, i64 1)
119119
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested1_,
120120
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), align 8
121-
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested1_, i64 1, i64 0),
121+
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested1_, i64 0, i64 2),
122122
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1, i32 1), align 8
123123
// CHECK-DYNAMIC-BE: store i32 5, ptr @_ZGR6nested2_
124124
// CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested2_, i64 1)
125125
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested2_,
126126
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 2), align 8
127-
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested2_, i64 1, i64 0),
127+
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr @_ZGR6nested2_, i64 0, i64 2),
128128
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 2, i32 1), align 8
129129
// CHECK-DYNAMIC-BE: store ptr @_ZGR6nested_,
130130
// CHECK-DYNAMIC-BE: ptr @nested, align 8
131-
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([3 x {{.*}}], ptr @_ZGR6nested_, i64 1, i64 0),
131+
// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([3 x {{.*}}], ptr @_ZGR6nested_, i64 0, i64 3),
132132
// CHECK-DYNAMIC-BE: ptr getelementptr inbounds ({{.*}}, ptr @nested, i32 0, i32 1), align 8

clang/test/CodeGenHLSL/cbuf.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ tbuffer A : register(t2, space1) {
1616

1717
float foo() {
1818
// CHECK: load float, ptr @[[CB]], align 4
19-
// CHECK: load double, ptr getelementptr inbounds ({ float, double }, ptr @[[CB]], i32 0, i32 1), align 8
19+
// CHECK: load double, ptr getelementptr ({ float, double }, ptr @[[CB]], i32 0, i32 1), align 8
2020
// CHECK: load float, ptr @[[TB]], align 4
21-
// CHECK: load double, ptr getelementptr inbounds ({ float, double }, ptr @[[TB]], i32 0, i32 1), align 8
21+
// CHECK: load double, ptr getelementptr ({ float, double }, ptr @[[TB]], i32 0, i32 1), align 8
2222
return a + b + c*d;
2323
}
2424

clang/test/Driver/linker-wrapper-image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
// OPENMP-REL: @.omp_offloading.device_image = internal unnamed_addr constant [[[SIZE:[0-9]+]] x i8] c"\10\FF\10\AD{{.*}}", section ".llvm.offloading.relocatable", align 8
2525

2626
// OPENMP: @.omp_offloading.device_image = internal unnamed_addr constant [[[SIZE:[0-9]+]] x i8] c"\10\FF\10\AD{{.*}}", section ".llvm.offloading", align 8
27-
// OPENMP-NEXT: @.omp_offloading.device_images = internal unnamed_addr constant [1 x %__tgt_device_image] [%__tgt_device_image { ptr getelementptr inbounds ([[[BEGIN:[0-9]+]] x i8], ptr @.omp_offloading.device_image, i64 1, i64 0), ptr getelementptr inbounds ([[[END:[0-9]+]] x i8], ptr @.omp_offloading.device_image, i64 1, i64 0), ptr @__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }]
27+
// OPENMP-NEXT: @.omp_offloading.device_images = internal unnamed_addr constant [1 x %__tgt_device_image] [%__tgt_device_image { ptr getelementptr ([[[BEGIN:[0-9]+]] x i8], ptr @.omp_offloading.device_image, i64 0, i64 144), ptr getelementptr ([[[END:[0-9]+]] x i8], ptr @.omp_offloading.device_image, i64 0, i64 144), ptr @__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }]
2828
// OPENMP-NEXT: @.omp_offloading.descriptor = internal constant %__tgt_bin_desc { i32 1, ptr @.omp_offloading.device_images, ptr @__start_omp_offloading_entries, ptr @__stop_omp_offloading_entries }
2929
// OPENMP-NEXT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 101, ptr @.omp_offloading.descriptor_reg, ptr null }]
3030

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
// RUN: echo 'section "__sancov_cntrs"' > patterns.txt
2828
// RUN: echo '%[0-9]\+ = load i8, ptr @__sancov_gen_' >> patterns.txt
2929
// RUN: echo 'store i8 %[0-9]\+, ptr @__sancov_gen_' >> patterns.txt
30-
// RUN: echo '%[0-9]\+ = load i8, ptr getelementptr inbounds (\[[0-9]\+ x i8\], ptr @__sancov_gen_' >> patterns.txt
31-
// RUN: echo 'store i8 %[0-9]\+, ptr getelementptr inbounds (\[[0-9]\+ x i8\], ptr @__sancov_gen_' >> patterns.txt
30+
// RUN: echo '%[0-9]\+ = load i8, ptr getelementptr (\[[0-9]\+ x i8\], ptr @__sancov_gen_' >> patterns.txt
31+
// RUN: echo 'store i8 %[0-9]\+, ptr getelementptr (\[[0-9]\+ x i8\], ptr @__sancov_gen_' >> patterns.txt
3232

3333
// Check indirect-calls
3434
// RUN: echo 'call void @__sanitizer_cov_trace_pc_indir' >> patterns.txt

llvm/lib/IR/ConstantFold.cpp

Lines changed: 0 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,50 +1417,6 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
14171417
return nullptr;
14181418
}
14191419

1420-
/// Test whether the given sequence of *normalized* indices is "inbounds".
1421-
template<typename IndexTy>
1422-
static bool isInBoundsIndices(ArrayRef<IndexTy> Idxs) {
1423-
// No indices means nothing that could be out of bounds.
1424-
if (Idxs.empty()) return true;
1425-
1426-
// If the first index is zero, it's in bounds.
1427-
if (cast<Constant>(Idxs[0])->isNullValue()) return true;
1428-
1429-
// If the first index is one and all the rest are zero, it's in bounds,
1430-
// by the one-past-the-end rule.
1431-
if (auto *CI = dyn_cast<ConstantInt>(Idxs[0])) {
1432-
if (!CI->isOne())
1433-
return false;
1434-
} else {
1435-
auto *CV = cast<ConstantDataVector>(Idxs[0]);
1436-
CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue());
1437-
if (!CI || !CI->isOne())
1438-
return false;
1439-
}
1440-
1441-
for (unsigned i = 1, e = Idxs.size(); i != e; ++i)
1442-
if (!cast<Constant>(Idxs[i])->isNullValue())
1443-
return false;
1444-
return true;
1445-
}
1446-
1447-
/// Test whether a given ConstantInt is in-range for a SequentialType.
1448-
static bool isIndexInRangeOfArrayType(uint64_t NumElements,
1449-
const ConstantInt *CI) {
1450-
// We cannot bounds check the index if it doesn't fit in an int64_t.
1451-
if (CI->getValue().getSignificantBits() > 64)
1452-
return false;
1453-
1454-
// A negative index or an index past the end of our sequential type is
1455-
// considered out-of-range.
1456-
int64_t IndexVal = CI->getSExtValue();
1457-
if (IndexVal < 0 || (IndexVal != 0 && (uint64_t)IndexVal >= NumElements))
1458-
return false;
1459-
1460-
// Otherwise, it is in-range.
1461-
return true;
1462-
}
1463-
14641420
// Combine Indices - If the source pointer to this getelementptr instruction
14651421
// is a getelementptr instruction, combine the indices of the two
14661422
// getelementptr instructions into a single instruction.
@@ -1572,157 +1528,5 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
15721528
if (Constant *C = foldGEPOfGEP(GEP, PointeeTy, InBounds, Idxs))
15731529
return C;
15741530

1575-
// Check to see if any array indices are not within the corresponding
1576-
// notional array or vector bounds. If so, try to determine if they can be
1577-
// factored out into preceding dimensions.
1578-
SmallVector<Constant *, 8> NewIdxs;
1579-
Type *Ty = PointeeTy;
1580-
Type *Prev = C->getType();
1581-
auto GEPIter = gep_type_begin(PointeeTy, Idxs);
1582-
bool Unknown =
1583-
!isa<ConstantInt>(Idxs[0]) && !isa<ConstantDataVector>(Idxs[0]);
1584-
for (unsigned i = 1, e = Idxs.size(); i != e;
1585-
Prev = Ty, Ty = (++GEPIter).getIndexedType(), ++i) {
1586-
if (!isa<ConstantInt>(Idxs[i]) && !isa<ConstantDataVector>(Idxs[i])) {
1587-
// We don't know if it's in range or not.
1588-
Unknown = true;
1589-
continue;
1590-
}
1591-
if (!isa<ConstantInt>(Idxs[i - 1]) && !isa<ConstantDataVector>(Idxs[i - 1]))
1592-
// Skip if the type of the previous index is not supported.
1593-
continue;
1594-
if (isa<StructType>(Ty)) {
1595-
// The verify makes sure that GEPs into a struct are in range.
1596-
continue;
1597-
}
1598-
if (isa<VectorType>(Ty)) {
1599-
// There can be awkward padding in after a non-power of two vector.
1600-
Unknown = true;
1601-
continue;
1602-
}
1603-
auto *STy = cast<ArrayType>(Ty);
1604-
if (ConstantInt *CI = dyn_cast<ConstantInt>(Idxs[i])) {
1605-
if (isIndexInRangeOfArrayType(STy->getNumElements(), CI))
1606-
// It's in range, skip to the next index.
1607-
continue;
1608-
if (CI->isNegative()) {
1609-
// It's out of range and negative, don't try to factor it.
1610-
Unknown = true;
1611-
continue;
1612-
}
1613-
} else {
1614-
auto *CV = cast<ConstantDataVector>(Idxs[i]);
1615-
bool IsInRange = true;
1616-
for (unsigned I = 0, E = CV->getNumElements(); I != E; ++I) {
1617-
auto *CI = cast<ConstantInt>(CV->getElementAsConstant(I));
1618-
IsInRange &= isIndexInRangeOfArrayType(STy->getNumElements(), CI);
1619-
if (CI->isNegative()) {
1620-
Unknown = true;
1621-
break;
1622-
}
1623-
}
1624-
if (IsInRange || Unknown)
1625-
// It's in range, skip to the next index.
1626-
// It's out of range and negative, don't try to factor it.
1627-
continue;
1628-
}
1629-
if (isa<StructType>(Prev)) {
1630-
// It's out of range, but the prior dimension is a struct
1631-
// so we can't do anything about it.
1632-
Unknown = true;
1633-
continue;
1634-
}
1635-
1636-
// Determine the number of elements in our sequential type.
1637-
uint64_t NumElements = STy->getArrayNumElements();
1638-
if (!NumElements) {
1639-
Unknown = true;
1640-
continue;
1641-
}
1642-
1643-
// It's out of range, but we can factor it into the prior
1644-
// dimension.
1645-
NewIdxs.resize(Idxs.size());
1646-
1647-
// Expand the current index or the previous index to a vector from a scalar
1648-
// if necessary.
1649-
Constant *CurrIdx = cast<Constant>(Idxs[i]);
1650-
auto *PrevIdx =
1651-
NewIdxs[i - 1] ? NewIdxs[i - 1] : cast<Constant>(Idxs[i - 1]);
1652-
bool IsCurrIdxVector = CurrIdx->getType()->isVectorTy();
1653-
bool IsPrevIdxVector = PrevIdx->getType()->isVectorTy();
1654-
bool UseVector = IsCurrIdxVector || IsPrevIdxVector;
1655-
1656-
if (!IsCurrIdxVector && IsPrevIdxVector)
1657-
CurrIdx = ConstantDataVector::getSplat(
1658-
cast<FixedVectorType>(PrevIdx->getType())->getNumElements(), CurrIdx);
1659-
1660-
if (!IsPrevIdxVector && IsCurrIdxVector)
1661-
PrevIdx = ConstantDataVector::getSplat(
1662-
cast<FixedVectorType>(CurrIdx->getType())->getNumElements(), PrevIdx);
1663-
1664-
Constant *Factor =
1665-
ConstantInt::get(CurrIdx->getType()->getScalarType(), NumElements);
1666-
if (UseVector)
1667-
Factor = ConstantDataVector::getSplat(
1668-
IsPrevIdxVector
1669-
? cast<FixedVectorType>(PrevIdx->getType())->getNumElements()
1670-
: cast<FixedVectorType>(CurrIdx->getType())->getNumElements(),
1671-
Factor);
1672-
1673-
NewIdxs[i] =
1674-
ConstantFoldBinaryInstruction(Instruction::SRem, CurrIdx, Factor);
1675-
1676-
Constant *Div =
1677-
ConstantFoldBinaryInstruction(Instruction::SDiv, CurrIdx, Factor);
1678-
1679-
// We're working on either ConstantInt or vectors of ConstantInt,
1680-
// so these should always fold.
1681-
assert(NewIdxs[i] != nullptr && Div != nullptr && "Should have folded");
1682-
1683-
unsigned CommonExtendedWidth =
1684-
std::max(PrevIdx->getType()->getScalarSizeInBits(),
1685-
Div->getType()->getScalarSizeInBits());
1686-
CommonExtendedWidth = std::max(CommonExtendedWidth, 64U);
1687-
1688-
// Before adding, extend both operands to i64 to avoid
1689-
// overflow trouble.
1690-
Type *ExtendedTy = Type::getIntNTy(Div->getContext(), CommonExtendedWidth);
1691-
if (UseVector)
1692-
ExtendedTy = FixedVectorType::get(
1693-
ExtendedTy,
1694-
IsPrevIdxVector
1695-
? cast<FixedVectorType>(PrevIdx->getType())->getNumElements()
1696-
: cast<FixedVectorType>(CurrIdx->getType())->getNumElements());
1697-
1698-
if (!PrevIdx->getType()->isIntOrIntVectorTy(CommonExtendedWidth))
1699-
PrevIdx =
1700-
ConstantFoldCastInstruction(Instruction::SExt, PrevIdx, ExtendedTy);
1701-
1702-
if (!Div->getType()->isIntOrIntVectorTy(CommonExtendedWidth))
1703-
Div = ConstantFoldCastInstruction(Instruction::SExt, Div, ExtendedTy);
1704-
1705-
assert(PrevIdx && Div && "Should have folded");
1706-
NewIdxs[i - 1] = ConstantExpr::getAdd(PrevIdx, Div);
1707-
}
1708-
1709-
// If we did any factoring, start over with the adjusted indices.
1710-
if (!NewIdxs.empty()) {
1711-
for (unsigned i = 0, e = Idxs.size(); i != e; ++i)
1712-
if (!NewIdxs[i]) NewIdxs[i] = cast<Constant>(Idxs[i]);
1713-
return ConstantExpr::getGetElementPtr(PointeeTy, C, NewIdxs, InBounds,
1714-
InRange);
1715-
}
1716-
1717-
// If all indices are known integers and normalized, we can do a simple
1718-
// check for the "inbounds" property.
1719-
if (!Unknown && !InBounds)
1720-
if (auto *GV = dyn_cast<GlobalVariable>(C))
1721-
if (!GV->hasExternalWeakLinkage() && GV->getValueType() == PointeeTy &&
1722-
isInBoundsIndices(Idxs))
1723-
// TODO(gep_nowrap): Can also set NUW here.
1724-
return ConstantExpr::getGetElementPtr(
1725-
PointeeTy, C, Idxs, GEPNoWrapFlags::inBounds(), InRange);
1726-
17271531
return nullptr;
17281532
}

llvm/test/Assembler/ConstantExprFold.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
; CHECK: @mul = global ptr null
4444
; CHECK: @xor = global ptr @A
4545
; CHECK: @B = external global %Ty
46-
; CHECK: @icmp_ult1 = global i1 icmp ugt (ptr getelementptr inbounds (i64, ptr @A, i64 1), ptr @A)
46+
; CHECK: @icmp_ult1 = global i1 icmp ugt (ptr getelementptr (i64, ptr @A, i64 1), ptr @A)
4747
; CHECK: @icmp_slt = global i1 false
48-
; CHECK: @icmp_ult2 = global i1 icmp ugt (ptr getelementptr inbounds (%Ty, ptr @B, i64 0, i32 1), ptr @B)
48+
; CHECK: @icmp_ult2 = global i1 icmp ugt (ptr getelementptr (%Ty, ptr @B, i64 0, i32 1), ptr @B)
4949
; CHECK: @cons = weak global i32 0, align 8
5050
; CHECK: @gep1 = global <2 x ptr> undef
5151
; CHECK: @gep2 = global <2 x ptr> undef

llvm/test/Assembler/getelementptr.ll

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
22
; RUN: verify-uselistorder %s
33

4-
; Verify that over-indexed getelementptrs are folded.
54
@A = external global [2 x [3 x [5 x [7 x i32]]]]
65
@B = global ptr getelementptr ([2 x [3 x [5 x [7 x i32]]]], ptr @A, i64 0, i64 0, i64 2, i64 1, i64 7523)
7-
; CHECK: @B = global ptr getelementptr ([2 x [3 x [5 x [7 x i32]]]], ptr @A, i64 36, i64 0, i64 1, i64 0, i64 5)
6+
; CHECK: @B = global ptr getelementptr ([2 x [3 x [5 x [7 x i32]]]], ptr @A, i64 0, i64 0, i64 2, i64 1, i64 7523)
87
@C = global ptr getelementptr ([2 x [3 x [5 x [7 x i32]]]], ptr @A, i64 3, i64 2, i64 0, i64 0, i64 7523)
9-
; CHECK: @C = global ptr getelementptr ([2 x [3 x [5 x [7 x i32]]]], ptr @A, i64 39, i64 1, i64 1, i64 4, i64 5)
8+
; CHECK: @C = global ptr getelementptr ([2 x [3 x [5 x [7 x i32]]]], ptr @A, i64 3, i64 2, i64 0, i64 0, i64 7523)
109

1110
; Verify that constant expression GEPs work with i84 indices.
1211
@D = external global [1 x i32]
1312

1413
@E = global ptr getelementptr inbounds ([1 x i32], ptr @D, i84 0, i64 1)
15-
; CHECK: @E = global ptr getelementptr inbounds ([1 x i32], ptr @D, i84 1, i64 0)
14+
; CHECK: @E = global ptr getelementptr inbounds ([1 x i32], ptr @D, i84 0, i64 1)
1615

1716
; Verify that i16 indices work.
1817
@x = external global {i32, i32}
@@ -23,16 +22,12 @@
2322
@PR23753_b = global ptr getelementptr (i8, ptr @PR23753_a, i64 ptrtoint (ptr @PR23753_a to i64))
2423
; CHECK: @PR23753_b = global ptr getelementptr (i8, ptr @PR23753_a, i64 ptrtoint (ptr @PR23753_a to i64))
2524

26-
; Verify that inrange doesn't inhibit over-indexed getelementptr folding,
27-
; but does inhibit combining two GEPs where the inner one has inrange (this
28-
; will be done when DataLayout is available instead).
29-
3025
@nestedarray = global [2 x [4 x ptr]] zeroinitializer
3126

32-
; CHECK: @nestedarray.1 = alias ptr, getelementptr inbounds inrange(-32, 32) ([2 x [4 x ptr]], ptr @nestedarray, i32 0, i64 1, i32 0)
27+
; CHECK: @nestedarray.1 = alias ptr, getelementptr inbounds inrange(-32, 32) ([2 x [4 x ptr]], ptr @nestedarray, i32 0, i32 0, i32 4)
3328
@nestedarray.1 = alias ptr, getelementptr inbounds inrange(-32, 32) ([2 x [4 x ptr]], ptr @nestedarray, i32 0, i32 0, i32 4)
3429

35-
; CHECK: @nestedarray.2 = alias ptr, getelementptr inbounds inrange(0, 1) ([2 x [4 x ptr]], ptr @nestedarray, i32 0, i64 1, i32 0)
30+
; CHECK: @nestedarray.2 = alias ptr, getelementptr inbounds inrange(0, 1) ([2 x [4 x ptr]], ptr @nestedarray, i32 0, i32 0, i32 4)
3631
@nestedarray.2 = alias ptr, getelementptr inbounds inrange(0, 1) ([2 x [4 x ptr]], ptr @nestedarray, i32 0, i32 0, i32 4)
3732

3833
; CHECK: @nestedarray.3 = alias ptr, getelementptr inbounds inrange(0, 4) ([4 x ptr], ptr @nestedarray, i32 0, i32 0)

llvm/test/Assembler/getelementptr_vec_ce.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@G = global [4 x i32] zeroinitializer
44

55
; CHECK-LABEL: @foo
6-
; CHECK: ret <4 x ptr> getelementptr inbounds ([4 x i32], ptr @G, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>)
6+
; CHECK: ret <4 x ptr> getelementptr ([4 x i32], ptr @G, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>)
77
define <4 x ptr> @foo() {
88
ret <4 x ptr> getelementptr ([4 x i32], ptr @G, i32 0, <4 x i32> <i32 0, i32 1, i32 2, i32 3>)
99
}

llvm/test/CodeGen/AMDGPU/opencl-printf.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ entry:
555555
define amdgpu_kernel void @test_indexed_format_str(i32 %n) {
556556
; R600-LABEL: @test_indexed_format_str(
557557
; R600-NEXT: entry:
558-
; R600-NEXT: [[CALL1:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) getelementptr inbounds ([11 x i8], ptr addrspace(4) @indexed.format.str, i64 0, i32 7), i32 [[N:%.*]])
558+
; R600-NEXT: [[CALL1:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) getelementptr ([11 x i8], ptr addrspace(4) @indexed.format.str, i64 0, i32 7), i32 [[N:%.*]])
559559
; R600-NEXT: ret void
560560
;
561561
; GCN-LABEL: @test_indexed_format_str(
@@ -583,7 +583,7 @@ entry:
583583
define amdgpu_kernel void @test_indexed_format_str_oob(i32 %n) {
584584
; R600-LABEL: @test_indexed_format_str_oob(
585585
; R600-NEXT: entry:
586-
; R600-NEXT: [[CALL1:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) getelementptr inbounds ([11 x i8], ptr addrspace(4) @indexed.format.str, i64 1, i64 0), i32 [[N:%.*]])
586+
; R600-NEXT: [[CALL1:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) getelementptr ([11 x i8], ptr addrspace(4) @indexed.format.str, i64 0, i64 11), i32 [[N:%.*]])
587587
; R600-NEXT: ret void
588588
;
589589
; GCN-LABEL: @test_indexed_format_str_oob(
@@ -1864,7 +1864,7 @@ entry:
18641864
define amdgpu_kernel void @test_print_string_indexed(i32 %n) {
18651865
; R600-LABEL: @test_print_string_indexed(
18661866
; R600-NEXT: entry:
1867-
; R600-NEXT: [[PRINTF:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @.str, ptr addrspace(4) getelementptr inbounds ([32 x i8], ptr addrspace(4) @printed.str.size32, i64 0, i64 15), i32 [[N:%.*]])
1867+
; R600-NEXT: [[PRINTF:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @.str, ptr addrspace(4) getelementptr ([32 x i8], ptr addrspace(4) @printed.str.size32, i64 0, i64 15), i32 [[N:%.*]])
18681868
; R600-NEXT: ret void
18691869
;
18701870
; GCN-LABEL: @test_print_string_indexed(
@@ -1900,7 +1900,7 @@ entry:
19001900
define amdgpu_kernel void @test_print_string_indexed_oob(i32 %n) {
19011901
; R600-LABEL: @test_print_string_indexed_oob(
19021902
; R600-NEXT: entry:
1903-
; R600-NEXT: [[PRINTF:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @.str, ptr addrspace(4) getelementptr inbounds ([32 x i8], ptr addrspace(4) @printed.str.size32, i64 1, i64 0), i32 [[N:%.*]])
1903+
; R600-NEXT: [[PRINTF:%.*]] = call i32 (ptr addrspace(4), ...) @printf(ptr addrspace(4) @.str, ptr addrspace(4) getelementptr ([32 x i8], ptr addrspace(4) @printed.str.size32, i64 0, i64 32), i32 [[N:%.*]])
19041904
; R600-NEXT: ret void
19051905
;
19061906
; GCN-LABEL: @test_print_string_indexed_oob(

0 commit comments

Comments
 (0)