forked from OSchip/llvm-project
[ConstraintElimination] Decompose GEP with arbitrary offsets.
This patch decomposes `GEP %x, %offset` as 0 + 1 * %x + 1 * %off.
This commit is contained in:
parent
dfe67f450e
commit
7fa14a7c69
|
@ -50,12 +50,16 @@ static SmallVector<std::pair<int64_t, Value *>, 4> decompose(Value *V) {
|
|||
return {{CI->getSExtValue(), nullptr}};
|
||||
}
|
||||
auto *GEP = dyn_cast<GetElementPtrInst>(V);
|
||||
if (GEP && GEP->getNumOperands() == 2 &&
|
||||
isa<ConstantInt>(GEP->getOperand(GEP->getNumOperands() - 1))) {
|
||||
return {{cast<ConstantInt>(GEP->getOperand(GEP->getNumOperands() - 1))
|
||||
->getSExtValue(),
|
||||
nullptr},
|
||||
{1, GEP->getPointerOperand()}};
|
||||
if (GEP && GEP->getNumOperands() == 2) {
|
||||
if (isa<ConstantInt>(GEP->getOperand(GEP->getNumOperands() - 1))) {
|
||||
return {{cast<ConstantInt>(GEP->getOperand(GEP->getNumOperands() - 1))
|
||||
->getSExtValue(),
|
||||
nullptr},
|
||||
{1, GEP->getPointerOperand()}};
|
||||
}
|
||||
return {{0, nullptr},
|
||||
{1, GEP->getPointerOperand()},
|
||||
{1, GEP->getOperand(GEP->getNumOperands() - 1)}};
|
||||
}
|
||||
|
||||
Value *Op0;
|
||||
|
|
|
@ -336,7 +336,7 @@ define void @test.not.uge.uge.nonconst(i8* %start, i8* %low, i8* %high, i64 %off
|
|||
; CHECK: if.then:
|
||||
; CHECK-NEXT: [[START_OFF_2:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 [[OFF]]
|
||||
; CHECK-NEXT: [[T_0:%.*]] = icmp uge i8* [[START_OFF_2]], [[HIGH]]
|
||||
; CHECK-NEXT: call void @use(i1 [[T_0]])
|
||||
; CHECK-NEXT: call void @use(i1 true)
|
||||
; CHECK-NEXT: ret void
|
||||
; CHECK: if.end:
|
||||
; CHECK-NEXT: [[START_1:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 1
|
||||
|
@ -344,7 +344,7 @@ define void @test.not.uge.uge.nonconst(i8* %start, i8* %low, i8* %high, i64 %off
|
|||
; CHECK-NEXT: call void @use(i1 [[C_0]])
|
||||
; CHECK-NEXT: [[START_OFF:%.*]] = getelementptr inbounds i8, i8* [[START]], i64 [[OFF]]
|
||||
; CHECK-NEXT: [[F_0:%.*]] = icmp uge i8* [[START_OFF]], [[HIGH]]
|
||||
; CHECK-NEXT: call void @use(i1 [[F_0]])
|
||||
; CHECK-NEXT: call void @use(i1 false)
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
entry:
|
||||
|
|
Loading…
Reference in New Issue