diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -6509,6 +6509,11 @@ if (ValAssumedPoison == V) return true; + auto *IAssumedPoison = dyn_cast(ValAssumedPoison); + auto *IV = dyn_cast(V); + if (IAssumedPoison && IV && IAssumedPoison->isIdenticalTo(IV)) + return true; + const unsigned MaxDepth = 2; if (Depth >= MaxDepth) return false; diff --git a/llvm/test/Transforms/InstCombine/signed-truncation-check.ll b/llvm/test/Transforms/InstCombine/signed-truncation-check.ll --- a/llvm/test/Transforms/InstCombine/signed-truncation-check.ll +++ b/llvm/test/Transforms/InstCombine/signed-truncation-check.ll @@ -661,7 +661,7 @@ ; CHECK-NEXT: call void @use32(i32 [[T4]]) ; CHECK-NEXT: [[T5:%.*]] = icmp eq i32 [[T4]], [[ARG]] ; CHECK-NEXT: call void @use1(i1 [[T5]]) -; CHECK-NEXT: [[T6:%.*]] = select i1 [[T2]], i1 [[T5]], i1 false +; CHECK-NEXT: [[T6:%.*]] = and i1 [[T2]], [[T5]] ; CHECK-NEXT: ret i1 [[T6]] ; %t1 = trunc i32 %arg to i8