[llvm-commits] [llvm] r125613 - in /llvm/trunk: include/llvm/Support/PatternMatch.h test/Transforms/InstCombine/vector-casts.ll

Nick Lewycky nicholas at mxc.ca
Tue Feb 15 15:13:23 PST 2011


Author: nicholas
Date: Tue Feb 15 17:13:23 2011
New Revision: 125613

URL: http://llvm.org/viewvc/llvm-project?rev=125613&view=rev
Log:
Teach PatternMatch that splat vectors could be floating point as well as
integer. Fixes PR9228!

Modified:
    llvm/trunk/include/llvm/Support/PatternMatch.h
    llvm/trunk/test/Transforms/InstCombine/vector-casts.ll

Modified: llvm/trunk/include/llvm/Support/PatternMatch.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PatternMatch.h?rev=125613&r1=125612&r2=125613&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PatternMatch.h (original)
+++ llvm/trunk/include/llvm/Support/PatternMatch.h Tue Feb 15 17:13:23 2011
@@ -81,7 +81,8 @@
       return true;
     }
     if (ConstantVector *CV = dyn_cast<ConstantVector>(V))
-      if (ConstantInt *CI = cast_or_null<ConstantInt>(CV->getSplatValue())) {
+      if (ConstantInt *CI =
+          dyn_cast_or_null<ConstantInt>(CV->getSplatValue())) {
         Res = &CI->getValue();
         return true;
       }
@@ -126,7 +127,7 @@
     if (const ConstantInt *CI = dyn_cast<ConstantInt>(V))
       return this->isValue(CI->getValue());
     if (const ConstantVector *CV = dyn_cast<ConstantVector>(V))
-      if (ConstantInt *CI = cast_or_null<ConstantInt>(CV->getSplatValue()))
+      if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue()))
         return this->isValue(CI->getValue());
     return false;
   }
@@ -146,7 +147,7 @@
         return true;
       }
     if (const ConstantVector *CV = dyn_cast<ConstantVector>(V))
-      if (ConstantInt *CI = cast_or_null<ConstantInt>(CV->getSplatValue()))
+      if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue()))
         if (this->isValue(CI->getValue())) {
           Res = &CI->getValue();
           return true;

Modified: llvm/trunk/test/Transforms/InstCombine/vector-casts.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vector-casts.ll?rev=125613&r1=125612&r2=125613&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/vector-casts.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/vector-casts.ll Tue Feb 15 17:13:23 2011
@@ -121,3 +121,31 @@
   %b = sitofp <2 x i64> %a to <2 x double>
   ret <2 x double> %b
 }
+
+; PR9228
+; This was a crasher, so no CHECK statements.
+define <4 x float> @f(i32 %a) nounwind alwaysinline {
+; CHECK: @f
+entry:
+  %dim = insertelement <4 x i32> undef, i32 %a, i32 0
+  %dim30 = insertelement <4 x i32> %dim, i32 %a, i32 1
+  %dim31 = insertelement <4 x i32> %dim30, i32 %a, i32 2
+  %dim32 = insertelement <4 x i32> %dim31, i32 %a, i32 3
+
+  %offset_ptr = getelementptr <4 x float>* null, i32 1
+  %offset_int = ptrtoint <4 x float>* %offset_ptr to i64
+  %sizeof32 = trunc i64 %offset_int to i32
+
+  %smearinsert33 = insertelement <4 x i32> undef, i32 %sizeof32, i32 0
+  %smearinsert34 = insertelement <4 x i32> %smearinsert33, i32 %sizeof32, i32 1
+  %smearinsert35 = insertelement <4 x i32> %smearinsert34, i32 %sizeof32, i32 2
+  %smearinsert36 = insertelement <4 x i32> %smearinsert35, i32 %sizeof32, i32 3
+
+  %delta_scale = mul <4 x i32> %dim32, %smearinsert36
+  %offset_delta = add <4 x i32> zeroinitializer, %delta_scale
+
+  %offset_varying_delta = add <4 x i32> %offset_delta, undef
+
+  ret <4 x float> undef
+}
+





More information about the llvm-commits mailing list