Commit 74311623 authored by Tom Stellard's avatar Tom Stellard
Browse files

Merging r200028:

------------------------------------------------------------------------
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.

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

llvm-svn: 206054
parent 221dfdbe
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -25,12 +25,14 @@ 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 (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;

+8 −0
Original line number Diff line number Diff line
@@ -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
}