[Float2Int] Don't operate on vector instructions
authorReid Kleckner <rnk@google.com>
Wed, 9 Dec 2015 21:08:18 +0000 (21:08 +0000)
committerReid Kleckner <rnk@google.com>
Wed, 9 Dec 2015 21:08:18 +0000 (21:08 +0000)
This fixes a crash bug. It's also not clear if we'd want to do this
transform for vectors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255155 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/Float2Int.cpp
test/Transforms/Float2Int/basic.ll

index a9a4a24f8e933cf4d0c36721471ada25937de539..7f5d78656b50bb85f2187f7befd6a1a00316be0e 100644 (file)
@@ -131,6 +131,8 @@ static Instruction::BinaryOps mapBinOpcode(unsigned Opcode) {
 // integer domain.
 void Float2Int::findRoots(Function &F, SmallPtrSet<Instruction*,8> &Roots) {
   for (auto &I : instructions(F)) {
 // integer domain.
 void Float2Int::findRoots(Function &F, SmallPtrSet<Instruction*,8> &Roots) {
   for (auto &I : instructions(F)) {
+    if (isa<VectorType>(I.getType()))
+      continue;
     switch (I.getOpcode()) {
     default: break;
     case Instruction::FPToUI:
     switch (I.getOpcode()) {
     default: break;
     case Instruction::FPToUI:
index f4d946914cd43bf772aa8192faec81b2faffbe84..7f04a594dc80ca53c65ffbb3f2bc36b5872036d9 100644 (file)
@@ -254,3 +254,13 @@ define i32 @neg_calluser(i32 %value) {
   ret i32 %7
 }
 declare double @g(double)
   ret i32 %7
 }
 declare double @g(double)
+
+; CHECK-LABEL: @neg_vector
+; CHECK:  %1 = uitofp <4 x i8> %a to <4 x float>
+; CHECK:  %2 = fptoui <4 x float> %1 to <4 x i16>
+; CHECK:  ret <4 x i16> %2
+define <4 x i16> @neg_vector(<4 x i8> %a) {
+  %1 = uitofp <4 x i8> %a to <4 x float>
+  %2 = fptoui <4 x float> %1 to <4 x i16>
+  ret <4 x i16> %2
+}