Index: llvm/lib/Analysis/LazyValueInfo.cpp =================================================================== --- llvm/lib/Analysis/LazyValueInfo.cpp +++ llvm/lib/Analysis/LazyValueInfo.cpp @@ -1861,7 +1861,14 @@ else if (Pred == ICmpInst::ICMP_NE) return LazyValueInfo::True; } - ValueLatticeElement Result = getImpl(PImpl, AC, &DL, DT).getValueAt(V, CxtI); + + // The getValueInBlock() result is valid anywhere in the block for non-pointer + // types. For pointer types, it will additionally take into account pointer + // dereferences anywhere in the block, so we need to use the more conservative + // getValueAt() function in this case. + ValueLatticeElement Result = V->getType()->isPointerTy() + ? getImpl(PImpl, AC, &DL, DT).getValueAt(V, CxtI) + : getImpl(PImpl, AC, &DL, DT).getValueInBlock(V, CxtI->getParent(), CxtI); Tristate Ret = getPredicateResult(Pred, C, Result, DL, TLI); if (Ret != Unknown) return Ret; Index: llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll =================================================================== --- llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll +++ llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll @@ -381,7 +381,7 @@ ; CHECK-NEXT: [[SHR:%.*]] = lshr i64 [[MUL]], 32 ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i64 [[SHR]] to i32 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[TRUNC]], 7 -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: ret i1 true ; %zext = zext i32 %x to i64 %mul = mul nuw i64 %zext, 7 @@ -397,7 +397,7 @@ ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i64 [[ZEXT]], 128 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i64 [[ADD]], 384 ; CHECK-NEXT: store i64 [[ADD]], i64* [[P:%.*]] -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: ret i1 true ; %zext = zext i8 %x to i64 %add = add nuw nsw i64 %zext, 128 Index: llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll =================================================================== --- llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll +++ llvm/test/Transforms/JumpThreading/bb-unreachable-from-entry.ll @@ -3,7 +3,12 @@ define void @foo() { ; CHECK-LABEL: define {{[^@]+}}@foo( -; CHECK-NEXT: exit2: +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[EXIT2:%.*]] +; CHECK: entry2: +; CHECK-NEXT: br label [[EXIT2]] +; CHECK: exit2: +; CHECK-NEXT: [[A0:%.*]] = phi i32 [ undef, [[ENTRY2:%.*]] ], [ 0, [[ENTRY:%.*]] ] ; CHECK-NEXT: ret void ; entry: Index: llvm/test/Transforms/JumpThreading/header-succ.ll =================================================================== --- llvm/test/Transforms/JumpThreading/header-succ.ll +++ llvm/test/Transforms/JumpThreading/header-succ.ll @@ -103,12 +103,13 @@ ; CHECK-NEXT: [[IND:%.*]] = phi i32 [ 0, [[TOP:%.*]] ], [ [[NEXTIND:%.*]], [[LATCH:%.*]] ] ; CHECK-NEXT: [[NEXTIND]] = add i32 [[IND]], 1 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[IND]], 10 -; CHECK-NEXT: br i1 [[CMP]], label [[LATCH]], label [[EXIT:%.*]] -; CHECK: latch: +; CHECK-NEXT: br i1 [[CMP]], label [[BODY:%.*]], label [[LATCH]] +; CHECK: body: ; CHECK-NEXT: call void @opaque_body() +; CHECK-NEXT: br label [[LATCH]] +; CHECK: latch: +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ undef, [[ENTRY]] ], [ 0, [[BODY]] ] ; CHECK-NEXT: br label [[ENTRY]] -; CHECK: exit: -; CHECK-NEXT: ret void ; top: br label %entry