@@ -126,7 +126,8 @@ bool GEPOperator::accumulateConstantOffset(
126126 APInt &Offset, function_ref<bool (Value &, APInt &)> ExternalAnalysis) {
127127 // Fast path for canonical getelementptr i8 form.
128128 if (SourceType->isIntegerTy (8 ) && !ExternalAnalysis) {
129- if (auto *CI = dyn_cast<ConstantInt>(Index.front ())) {
129+ auto *CI = dyn_cast<ConstantInt>(Index.front ());
130+ if (CI && CI->getType ()->isIntegerTy ()) {
130131 Offset += CI->getValue ().sextOrTrunc (Offset.getBitWidth ());
131132 return true ;
132133 }
@@ -165,7 +166,8 @@ bool GEPOperator::accumulateConstantOffset(
165166 Value *V = GTI.getOperand ();
166167 StructType *STy = GTI.getStructTypeOrNull ();
167168 // Handle ConstantInt if possible.
168- if (auto ConstOffset = dyn_cast<ConstantInt>(V)) {
169+ auto *ConstOffset = dyn_cast<ConstantInt>(V);
170+ if (ConstOffset && ConstOffset->getType ()->isIntegerTy ()) {
169171 if (ConstOffset->isZero ())
170172 continue ;
171173 // if the type is scalable and the constant is not zero (vscale * n * 0 =
@@ -226,7 +228,8 @@ bool GEPOperator::collectOffset(
226228 Value *V = GTI.getOperand ();
227229 StructType *STy = GTI.getStructTypeOrNull ();
228230 // Handle ConstantInt if possible.
229- if (auto ConstOffset = dyn_cast<ConstantInt>(V)) {
231+ auto *ConstOffset = dyn_cast<ConstantInt>(V);
232+ if (ConstOffset && ConstOffset->getType ()->isIntegerTy ()) {
230233 if (ConstOffset->isZero ())
231234 continue ;
232235 // If the type is scalable and the constant is not zero (vscale * n * 0 =
0 commit comments