]> granicus.if.org Git - llvm/commitdiff
Merging r200028:
authorTom Stellard <thomas.stellard@amd.com>
Fri, 11 Apr 2014 19:35:42 +0000 (19:35 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Fri, 11 Apr 2014 19:35:42 +0000 (19:35 +0000)
------------------------------------------------------------------------
r200028 | benny.kra | 2014-01-24 14:02:37 -0500 (Fri, 24 Jan 2014) | 4 lines

InstCombine: Don't try to use aggregate elements of ConstantExprs.

PR18600.

------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@206054 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineVectorOps.cpp
test/Transforms/InstCombine/vec_extract_var_elt.ll

index 1e724106991a4c879eaad39aa659bb97086a7d50..30290ee7a799ad7fb6a6cd66e141ea04d944e887 100644 (file)
@@ -25,11 +25,13 @@ static bool CheapToScalarize(Value *V, bool isConstant) {
     if (isConstant) return true;
 
     // If all elts are the same, we can extract it and use any of the values.
-    Constant *Op0 = C->getAggregateElement(0U);
-    for (unsigned i = 1, e = V->getType()->getVectorNumElements(); i != e; ++i)
-      if (C->getAggregateElement(i) != Op0)
-        return false;
-    return true;
+    if (Constant *Op0 = C->getAggregateElement(0U)) {
+      for (unsigned i = 1, e = V->getType()->getVectorNumElements(); i != e;
+           ++i)
+        if (C->getAggregateElement(i) != Op0)
+          return false;
+      return true;
+    }
   }
   Instruction *I = dyn_cast<Instruction>(V);
   if (!I) return false;
index 3c982873e288195667d6028eb10efe82d95f5320..f6f9e0134a163809ae8dc372275487ec77e5c582 100644 (file)
@@ -16,3 +16,11 @@ define void @test (float %b, <8 x float> * %p)  {
   ret void    
 }
 
+; PR18600
+define i32 @test2(i32 %i) {
+  %e = extractelement <4 x i32> bitcast (<2 x i64> <i64 1, i64 2> to <4 x i32>), i32 %i
+  ret i32 %e
+
+; CHECK-LABEL: @test2
+; CHECK: extractelement
+}