With the semantics change from D154051, it is no longer valid to
fold gep inbounds undef to poison (unless we know the index is
non-zero). Fold it to undef instead.
Differential Revision: https://reviews.llvm.org/D154215
any_of(Indices, [](const auto *V) { return isa<PoisonValue>(V); }))
return PoisonValue::get(GEPTy);
+ // getelementptr undef, idx -> undef
if (Q.isUndefValue(Ptr))
- // If inbounds, we can choose an out-of-bounds pointer as a base pointer.
- return InBounds ? PoisonValue::get(GEPTy) : UndefValue::get(GEPTy);
+ return UndefValue::get(GEPTy);
bool IsScalableVec =
isa<ScalableVectorType>(SrcTy) || any_of(Indices, [](const Value *V) {
define ptr @undef_inbounds_var_idx(i64 %idx) {
; CHECK-LABEL: @undef_inbounds_var_idx(
-; CHECK-NEXT: ret ptr poison
+; CHECK-NEXT: ret ptr undef
;
%el = getelementptr inbounds i64, ptr undef, i64 %idx
ret ptr %el
define <8 x ptr> @undef_vec1() {
; CHECK-LABEL: @undef_vec1(
-; CHECK-NEXT: ret <8 x ptr> poison
+; CHECK-NEXT: ret <8 x ptr> undef
;
%el = getelementptr inbounds i64, ptr undef, <8 x i64> undef
ret <8 x ptr> %el