Skip to content

Commit

Permalink
[ConstantFolding] Remove some typed pointer handling (NFC)
Browse files Browse the repository at this point in the history
No need to insert a bitcast.
  • Loading branch information
nikic committed Jul 18, 2023
1 parent 6f653d9 commit e65cabb
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions llvm/lib/Analysis/ConstantFolding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,18 +1001,8 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
}

// Create a GEP.
Constant *C = ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs,
InBounds, InRangeIndex);
assert(
cast<PointerType>(C->getType())->isOpaqueOrPointeeTypeMatches(ElemTy) &&
"Computed GetElementPtr has unexpected type!");

// If we ended up indexing a member with a type that doesn't match
// the type of what the original indices indexed, add a cast.
if (C->getType() != ResTy)
C = FoldBitCast(C, ResTy, DL);

return C;
return ConstantExpr::getGetElementPtr(SrcElemTy, Ptr, NewIdxs, InBounds,
InRangeIndex);
}

/// Attempt to constant fold an instruction with the
Expand Down

0 comments on commit e65cabb

Please sign in to comment.