Skip to content

Commit 3628bb7

Browse files
committed
Make various assume bundle data structures use uint64_t
Following D110451, we need to make sure to support 64 bit values.
1 parent a652e5b commit 3628bb7

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

llvm/include/llvm/Analysis/AssumeBundleQueries.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ template<> struct DenseMapInfo<Attribute::AttrKind> {
7070
using RetainedKnowledgeKey = std::pair<Value *, Attribute::AttrKind>;
7171

7272
struct MinMax {
73-
unsigned Min;
74-
unsigned Max;
73+
uint64_t Min;
74+
uint64_t Max;
7575
};
7676

7777
/// A mapping from intrinsics (=`llvm.assume` calls) to a value range
@@ -100,7 +100,7 @@ void fillMapFromAssume(AssumeInst &Assume, RetainedKnowledgeMap &Result);
100100
/// - ArgValue will be 4.
101101
struct RetainedKnowledge {
102102
Attribute::AttrKind AttrKind = Attribute::None;
103-
unsigned ArgValue = 0;
103+
uint64_t ArgValue = 0;
104104
Value *WasOn = nullptr;
105105
bool operator==(RetainedKnowledge Other) const {
106106
return AttrKind == Other.AttrKind && WasOn == Other.WasOn &&

llvm/lib/Analysis/AssumeBundleQueries.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void llvm::fillMapFromAssume(AssumeInst &Assume, RetainedKnowledgeMap &Result) {
8484
getValueFromBundleOpInfo(Assume, Bundles, ABA_Argument));
8585
if (!CI)
8686
continue;
87-
unsigned Val = CI->getZExtValue();
87+
uint64_t Val = CI->getZExtValue();
8888
auto Lookup = Result.find(Key);
8989
if (Lookup == Result.end() || !Lookup->second.count(&Assume)) {
9090
Result[Key][&Assume] = {Val, Val};
@@ -102,7 +102,7 @@ llvm::getKnowledgeFromBundle(AssumeInst &Assume,
102102
Result.AttrKind = Attribute::getAttrKindFromName(BOI.Tag->getKey());
103103
if (bundleHasArgument(BOI, ABA_WasOn))
104104
Result.WasOn = getValueFromBundleOpInfo(Assume, BOI, ABA_WasOn);
105-
auto GetArgOr1 = [&](unsigned Idx) -> unsigned {
105+
auto GetArgOr1 = [&](unsigned Idx) -> uint64_t {
106106
if (auto *ConstInt = dyn_cast<ConstantInt>(
107107
getValueFromBundleOpInfo(Assume, BOI, ABA_Argument + Idx)))
108108
return ConstInt->getZExtValue();

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static void computeKnownBitsFromAssume(const Value *V, KnownBits &Known,
635635
if (V->getType()->isPointerTy()) {
636636
if (RetainedKnowledge RK = getKnowledgeValidInContext(
637637
V, {Attribute::Alignment}, Q.CxtI, Q.DT, Q.AC)) {
638-
Known.Zero.setLowBits(Log2_32(RK.ArgValue));
638+
Known.Zero.setLowBits(Log2_64(RK.ArgValue));
639639
}
640640
}
641641

llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct AssumeBuilderState {
104104
Module *M;
105105

106106
using MapKey = std::pair<Value *, Attribute::AttrKind>;
107-
SmallMapVector<MapKey, unsigned, 8> AssumedKnowledgeMap;
107+
SmallMapVector<MapKey, uint64_t, 8> AssumedKnowledgeMap;
108108
Instruction *InstBeingModified = nullptr;
109109
AssumptionCache* AC = nullptr;
110110
DominatorTree* DT = nullptr;
@@ -197,7 +197,7 @@ struct AssumeBuilderState {
197197
(!ShouldPreserveAllAttributes &&
198198
!isUsefullToPreserve(Attr.getKindAsEnum())))
199199
return;
200-
unsigned AttrArg = 0;
200+
uint64_t AttrArg = 0;
201201
if (Attr.isIntAttribute())
202202
AttrArg = Attr.getValueAsInt();
203203
addKnowledge({Attr.getKindAsEnum(), AttrArg, WasOn});
@@ -261,8 +261,7 @@ struct AssumeBuilderState {
261261
addKnowledge({Attribute::NonNull, 0u, Pointer});
262262
}
263263
if (MA.valueOrOne() > 1)
264-
addKnowledge(
265-
{Attribute::Alignment, unsigned(MA.valueOrOne().value()), Pointer});
264+
addKnowledge({Attribute::Alignment, MA.valueOrOne().value(), Pointer});
266265
}
267266

268267
void addInstruction(Instruction *I) {
@@ -392,7 +391,7 @@ struct AssumeSimplify {
392391
void dropRedundantKnowledge() {
393392
struct MapValue {
394393
IntrinsicInst *Assume;
395-
unsigned ArgValue;
394+
uint64_t ArgValue;
396395
CallInst::BundleOpInfo *BOI;
397396
};
398397
buildMapping(false);

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,20 @@ if.end: ; preds = %if.else, %if.then
8888
ret void
8989
}
9090

91+
define void @f3(i64 %a, i8* %b) {
92+
; CHECK-LABEL: @f3(
93+
; CHECK-NEXT: [[C:%.*]] = ptrtoint i8* [[B:%.*]] to i64
94+
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(i8* [[B]], i64 4294967296) ]
95+
; CHECK-NEXT: [[D:%.*]] = add i64 [[C]], [[A:%.*]]
96+
; CHECK-NEXT: call void @g(i64 [[D]])
97+
; CHECK-NEXT: ret void
98+
;
99+
%c = ptrtoint i8* %b to i64
100+
call void @llvm.assume(i1 true) [ "align"(i8* %b, i64 4294967296) ]
101+
%d = add i64 %a, %c
102+
call void @g(i64 %d)
103+
ret void
104+
}
105+
106+
declare void @g(i64)
107+

0 commit comments

Comments
 (0)