[llvm-commits] [llvm] r126058 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineVectorOps.cpp test/Transforms/InstCombine/2011-02-16-InsertelementHang.ll

Eli Friedman eli.friedman at gmail.com
Sat Feb 19 14:42:40 PST 2011


Author: efriedma
Date: Sat Feb 19 16:42:40 2011
New Revision: 126058

URL: http://llvm.org/viewvc/llvm-project?rev=126058&view=rev
Log:
PR9218: SimplifyDemandedVectorElts can return a non-null value that is not
the instruction passed in.  Make sure to account for this correctly, instead
of looping infinitely.


Added:
    llvm/trunk/test/Transforms/InstCombine/2011-02-16-InsertelementHang.ll
Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=126058&r1=126057&r2=126058&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Sat Feb 19 16:42:40 2011
@@ -426,8 +426,11 @@
   unsigned VWidth = cast<VectorType>(VecOp->getType())->getNumElements();
   APInt UndefElts(VWidth, 0);
   APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
-  if (SimplifyDemandedVectorElts(&IE, AllOnesEltMask, UndefElts))
+  if (Value *V = SimplifyDemandedVectorElts(&IE, AllOnesEltMask, UndefElts)) {
+    if (V != &IE)
+      return ReplaceInstUsesWith(IE, V);
     return &IE;
+  }
 
   return 0;
 }
@@ -451,7 +454,9 @@
 
   APInt UndefElts(VWidth, 0);
   APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));
-  if (SimplifyDemandedVectorElts(&SVI, AllOnesEltMask, UndefElts)) {
+  if (Value *V = SimplifyDemandedVectorElts(&SVI, AllOnesEltMask, UndefElts)) {
+    if (V != &SVI)
+      return ReplaceInstUsesWith(SVI, V);
     LHS = SVI.getOperand(0);
     RHS = SVI.getOperand(1);
     MadeChange = true;

Added: llvm/trunk/test/Transforms/InstCombine/2011-02-16-InsertelementHang.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2011-02-16-InsertelementHang.ll?rev=126058&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/2011-02-16-InsertelementHang.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/2011-02-16-InsertelementHang.ll Sat Feb 19 16:42:40 2011
@@ -0,0 +1,11 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; PR9218
+
+%vec2x2 = type { <2 x double>, <2 x double> }
+
+define %vec2x2 @split(double) nounwind alwaysinline {
+; CHECK: @split
+; CHECK: ret %vec2x2 undef
+  %vba = insertelement <2 x double> undef, double %0, i32 2
+  ret <2 x double> %vba, <2 x double> %vba
+}





More information about the llvm-commits mailing list