mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-05 02:49:18 +00:00
[InstCombine] Use replaceOperand() API in GEP transforms
To make sure that replaced operands get DCEd. This drops one iteration from gepphigep.ll, which is still not optimal. This was the last test case performing more than 3 iterations. NFC-ish, only worklist order should change.
This commit is contained in:
parent
b7e2a09400
commit
f72f98d666
@ -1996,7 +1996,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
||||
|
||||
GEP.getParent()->getInstList().insert(
|
||||
GEP.getParent()->getFirstInsertionPt(), NewGEP);
|
||||
GEP.setOperand(0, NewGEP);
|
||||
replaceOperand(GEP, 0, NewGEP);
|
||||
PtrOp = NewGEP;
|
||||
}
|
||||
|
||||
@ -2096,8 +2096,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
||||
// Update the GEP in place if possible.
|
||||
if (Src->getNumOperands() == 2) {
|
||||
GEP.setIsInBounds(isMergedGEPInBounds(*Src, *cast<GEPOperator>(&GEP)));
|
||||
GEP.setOperand(0, Src->getOperand(0));
|
||||
GEP.setOperand(1, Sum);
|
||||
replaceOperand(GEP, 0, Src->getOperand(0));
|
||||
replaceOperand(GEP, 1, Sum);
|
||||
return &GEP;
|
||||
}
|
||||
Indices.append(Src->op_begin()+1, Src->op_end()-1);
|
||||
@ -2215,9 +2215,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
||||
// array. Because the array type is never stepped over (there
|
||||
// is a leading zero) we can fold the cast into this GEP.
|
||||
if (StrippedPtrTy->getAddressSpace() == GEP.getAddressSpace()) {
|
||||
GEP.setOperand(0, StrippedPtr);
|
||||
GEP.setSourceElementType(XATy);
|
||||
return &GEP;
|
||||
return replaceOperand(GEP, 0, StrippedPtr);
|
||||
}
|
||||
// Cannot replace the base pointer directly because StrippedPtr's
|
||||
// address space is different. Instead, create a new GEP followed by
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt -instcombine -S < %s | FileCheck %s
|
||||
; RUN: opt -instcombine -instcombine-infinite-loop-threshold=3 -S < %s | FileCheck %s
|
||||
|
||||
%struct1 = type { %struct2*, i32, i32, i32 }
|
||||
%struct2 = type { i32, i32 }
|
||||
|
Loading…
x
Reference in New Issue
Block a user