diff --git a/llvm/include/llvm/Analysis/InstructionSimplify.h b/llvm/include/llvm/Analysis/InstructionSimplify.h --- a/llvm/include/llvm/Analysis/InstructionSimplify.h +++ b/llvm/include/llvm/Analysis/InstructionSimplify.h @@ -133,7 +133,22 @@ bool isUndefValue(Value *V) const { if (!CanUseUndef) return false; - return isa(V); + + if (isa(V)) + return true; + + // Check whether V is e.g., + Constant *C = dyn_cast(V); + auto *FVTy = dyn_cast(V->getType()); + if (C && FVTy) { + for (unsigned i = 0, e = FVTy->getNumElements(); i != e; ++i) { + auto *EV = C->getAggregateElement(i); + if (!EV || !isa(EV)) + return false; + } + return true; + } + return false; } }; diff --git a/llvm/test/Transforms/InstSimplify/icmp-constant.ll b/llvm/test/Transforms/InstSimplify/icmp-constant.ll --- a/llvm/test/Transforms/InstSimplify/icmp-constant.ll +++ b/llvm/test/Transforms/InstSimplify/icmp-constant.ll @@ -1069,8 +1069,7 @@ define <2 x i1> @heterogeneous_constvector(<2 x i8> %x) { ; CHECK-LABEL: @heterogeneous_constvector( -; CHECK-NEXT: [[C:%.*]] = icmp ult <2 x i8> [[X:%.*]], -; CHECK-NEXT: ret <2 x i1> [[C]] +; CHECK-NEXT: ret <2 x i1> zeroinitializer ; %c = icmp ult <2 x i8> %x, ret <2 x i1> %c