mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
Don't duplicate the work done by a gep into a "bitcast" if the gep has
more than one use. Fixes PR10322. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134883 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -785,6 +785,14 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
||||
// getelementptr instructions into a single instruction.
|
||||
//
|
||||
if (GEPOperator *Src = dyn_cast<GEPOperator>(PtrOp)) {
|
||||
|
||||
// If this GEP has only 0 indices, it is the same pointer as
|
||||
// Src. If Src is not a trivial GEP too, don't combine
|
||||
// the indices.
|
||||
if (GEP.hasAllZeroIndices() && !Src->hasAllZeroIndices() &&
|
||||
!Src->hasOneUse())
|
||||
return 0;
|
||||
|
||||
// Note that if our source is a gep chain itself that we wait for that
|
||||
// chain to be resolved before we perform this transformation. This
|
||||
// avoids us creating a TON of code in some cases.
|
||||
|
Reference in New Issue
Block a user