From f38d47144572275396e6e6611fa5e181e79b2944 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 7 Apr 2006 04:44:06 +0000 Subject: [PATCH] Constant fold extractelement(zero, x) -> zero git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27479 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/ConstantFold.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index d63fb6b2db1..94c8651609d 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -836,6 +836,9 @@ Constant *llvm::ConstantFoldExtractElementInstruction(const Constant *Val, const Constant *Idx) { if (isa(Val)) // ee(undef, x) -> undef return UndefValue::get(cast(Val->getType())->getElementType()); + if (Val->isNullValue()) // ee(zero, x) -> zero + return Constant::getNullValue( + cast(Val->getType())->getElementType()); if (const ConstantPacked *CVal = dyn_cast(Val)) { if (const ConstantUInt *CIdx = dyn_cast(Idx)) {