@@ -71,8 +71,8 @@ static Value *simplifyXorInst(Value *, Value *, const SimplifyQuery &,
7171 unsigned );
7272static Value *simplifyCastInst (unsigned , Value *, Type *, const SimplifyQuery &,
7373 unsigned );
74- static Value *simplifyGEPInst (Type *, Value *, ArrayRef<Value *>, bool ,
75- const SimplifyQuery &, unsigned );
74+ static Value *simplifyGEPInst (Type *, Value *, ArrayRef<Value *>,
75+ GEPNoWrapFlags, const SimplifyQuery &, unsigned );
7676static Value *simplifySelectInst (Value *, Value *, Value *,
7777 const SimplifyQuery &, unsigned );
7878static Value *simplifyInstructionWithOperands (Instruction *I,
@@ -4943,7 +4943,7 @@ Value *llvm::simplifySelectInst(Value *Cond, Value *TrueVal, Value *FalseVal,
49434943// / Given operands for an GetElementPtrInst, see if we can fold the result.
49444944// / If not, this returns null.
49454945static Value *simplifyGEPInst (Type *SrcTy, Value *Ptr,
4946- ArrayRef<Value *> Indices, bool InBounds ,
4946+ ArrayRef<Value *> Indices, GEPNoWrapFlags NW ,
49474947 const SimplifyQuery &Q, unsigned ) {
49484948 // The type of the GEP pointer operand.
49494949 unsigned AS =
@@ -5068,17 +5068,18 @@ static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr,
50685068 return nullptr ;
50695069
50705070 if (!ConstantExpr::isSupportedGetElementPtr (SrcTy))
5071- return ConstantFoldGetElementPtr (SrcTy, cast<Constant>(Ptr), InBounds,
5072- std::nullopt , Indices);
5071+ // TODO(gep_nowrap): Pass on the whole GEPNoWrapFlags.
5072+ return ConstantFoldGetElementPtr (SrcTy, cast<Constant>(Ptr),
5073+ NW.isInBounds (), std::nullopt , Indices);
50735074
5074- auto *CE = ConstantExpr::getGetElementPtr (SrcTy, cast<Constant>(Ptr), Indices,
5075- InBounds );
5075+ auto *CE =
5076+ ConstantExpr::getGetElementPtr (SrcTy, cast<Constant>(Ptr), Indices, NW );
50765077 return ConstantFoldConstant (CE, Q.DL );
50775078}
50785079
50795080Value *llvm::simplifyGEPInst (Type *SrcTy, Value *Ptr, ArrayRef<Value *> Indices,
5080- bool InBounds , const SimplifyQuery &Q) {
5081- return ::simplifyGEPInst (SrcTy, Ptr, Indices, InBounds , Q, RecursionLimit);
5081+ GEPNoWrapFlags NW , const SimplifyQuery &Q) {
5082+ return ::simplifyGEPInst (SrcTy, Ptr, Indices, NW , Q, RecursionLimit);
50825083}
50835084
50845085// / Given operands for an InsertValueInst, see if we can fold the result.
@@ -7077,7 +7078,7 @@ static Value *simplifyInstructionWithOperands(Instruction *I,
70777078 case Instruction::GetElementPtr: {
70787079 auto *GEPI = cast<GetElementPtrInst>(I);
70797080 return simplifyGEPInst (GEPI->getSourceElementType (), NewOps[0 ],
7080- ArrayRef (NewOps).slice (1 ), GEPI->isInBounds (), Q,
7081+ ArrayRef (NewOps).slice (1 ), GEPI->getNoWrapFlags (), Q,
70817082 MaxRecurse);
70827083 }
70837084 case Instruction::InsertValue: {
0 commit comments