Fixed an assertion failure for tracking sext of a vector of integers
authorMon P Wang <wangmp@apple.com>
Wed, 2 Dec 2009 04:59:58 +0000 (04:59 +0000)
committerMon P Wang <wangmp@apple.com>
Wed, 2 Dec 2009 04:59:58 +0000 (04:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90290 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueTracking.cpp
test/Transforms/InstCombine/sext-2.ll [new file with mode: 0644]

index 31d3ccca36adedd2a03c8316f9591d8dfdb0dc43..22c6e3b6f121145c7579d87186e6072106b4bc23 100644 (file)
@@ -659,7 +659,7 @@ unsigned llvm::ComputeNumSignBits(Value *V, const TargetData *TD,
   switch (Operator::getOpcode(V)) {
   default: break;
   case Instruction::SExt:
-    Tmp = TyBits-cast<IntegerType>(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 (file)
index 0000000..39d4a3c
--- /dev/null
@@ -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, <i16 15, i16 15> ;
+  store <2 x i16> %tmask, <2 x i16>* %dst;                                                                   
+  ret void                                                                                                                      
+}