From 91ac05d480c45d0783498681f0382d83658f652e Mon Sep 17 00:00:00 2001 From: Mon P Wang Date: Wed, 2 Dec 2009 04:59:58 +0000 Subject: [PATCH] Fixed an assertion failure for tracking sext of a vector of integers llvm-svn: 90290 --- lib/Analysis/ValueTracking.cpp | 2 +- test/Transforms/InstCombine/sext-2.ll | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/InstCombine/sext-2.ll diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 31d3ccca36a..22c6e3b6f12 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -659,7 +659,7 @@ unsigned llvm::ComputeNumSignBits(Value *V, const TargetData *TD, switch (Operator::getOpcode(V)) { default: break; case Instruction::SExt: - Tmp = TyBits-cast(U->getOperand(0)->getType())->getBitWidth(); + Tmp = TyBits - U->getOperand(0)->getType()->getScalarSizeInBits(); return ComputeNumSignBits(U->getOperand(0), TD, Depth+1) + Tmp; case Instruction::AShr: diff --git a/test/Transforms/InstCombine/sext-2.ll b/test/Transforms/InstCombine/sext-2.ll new file mode 100644 index 00000000000..39d4a3c3d56 --- /dev/null +++ b/test/Transforms/InstCombine/sext-2.ll @@ -0,0 +1,14 @@ +; Checks to see that instcombine can handle a sign extension of i1 + +; RUN: opt < %s -instcombine -S | FileCheck %s + +define void @test(<2 x i16> %srcA, <2 x i16> %srcB, <2 x i16>* %dst) nounwind { +entry: +; CHECK-NOT: tmask +; CHECK: ret + %cmp = icmp eq <2 x i16> %srcB, %srcA; + %sext = sext <2 x i1> %cmp to <2 x i16>; + %tmask = ashr <2 x i16> %sext, ; + store <2 x i16> %tmask, <2 x i16>* %dst; + ret void +}