<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I would like to see this change go into the 3.3 release branch. <div><br><div><div>On May 7, 2013, at 7:46 PM, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">ccing Nadav as I think he is the one that has to approve the patch for 3.3.<br><br>On 7 May 2013 09:02, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br><blockquote type="cite">This just missed 3.3 branching. I would like to nominate it for<br>backporting as without it firefox is miscompiled.<br><br>On 7 May 2013 00:37, Arnold Schwaighofer <<a href="mailto:aschwaighofer@apple.com">aschwaighofer@apple.com</a>> wrote:<br><blockquote type="cite">Author: arnolds<br>Date: Mon May  6 23:37:05 2013<br>New Revision: 181286<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=181286&view=rev">http://llvm.org/viewvc/llvm-project?rev=181286&view=rev</a><br>Log:<br>LoopVectorize: getConsecutiveVector must respect signed arithmetic<br><br>We were passing an i32 to ConstantInt::get where an i64 was needed and we must<br>also pass the sign if we pass negatives numbers. The start index passed to<br>getConsecutiveVector must also be signed.<br><br>Should fix PR15882.<br><br>Added:<br>   llvm/trunk/test/Transforms/LoopVectorize/reverse_induction.ll<br>Modified:<br>   llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp<br><br>Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=181286&r1=181285&r2=181286&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=181286&r1=181285&r2=181286&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Mon May  6 23:37:05 2013<br>@@ -216,7 +216,7 @@ private:<br>  /// This function adds 0, 1, 2 ... to each vector element, starting at zero.<br>  /// If Negate is set then negative numbers are added e.g. (0, -1, -2, ...).<br>  /// The sequence starts at StartIndex.<br>-  Value *getConsecutiveVector(Value* Val, unsigned StartIdx, bool Negate);<br>+  Value *getConsecutiveVector(Value* Val, int StartIdx, bool Negate);<br><br>  /// When we go over instructions in the basic block we rely on previous<br>  /// values within the current basic block or on loop invariant values.<br>@@ -829,7 +829,7 @@ Value *InnerLoopVectorizer::getBroadcast<br>  return Shuf;<br>}<br><br>-Value *InnerLoopVectorizer::getConsecutiveVector(Value* Val, unsigned StartIdx,<br>+Value *InnerLoopVectorizer::getConsecutiveVector(Value* Val, int StartIdx,<br>                                                 bool Negate) {<br>  assert(Val->getType()->isVectorTy() && "Must be a vector");<br>  assert(Val->getType()->getScalarType()->isIntegerTy() &&<br>@@ -842,8 +842,8 @@ Value *InnerLoopVectorizer::getConsecuti<br><br>  // Create a vector of consecutive numbers from zero to VF.<br>  for (int i = 0; i < VLen; ++i) {<br>-    int Idx = Negate ? (-i): i;<br>-    Indices.push_back(ConstantInt::get(ITy, StartIdx + Idx));<br>+    int64_t Idx = Negate ? (-i) : i;<br>+    Indices.push_back(ConstantInt::get(ITy, StartIdx + Idx, Negate));<br>  }<br><br>  // Add the consecutive indices to the vector value.<br>@@ -2072,7 +2072,8 @@ InnerLoopVectorizer::vectorizeBlockInLoo<br>          // After broadcasting the induction variable we need to make the<br>          // vector consecutive by adding  ... -3, -2, -1, 0.<br>          for (unsigned part = 0; part < UF; ++part)<br>-            Entry[part] = getConsecutiveVector(Broadcasted, -VF * part, true);<br>+            Entry[part] = getConsecutiveVector(Broadcasted, -(int)VF * part,<br>+                                               true);<br>          continue;<br>        }<br><br><br>Added: llvm/trunk/test/Transforms/LoopVectorize/reverse_induction.ll<br>URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/reverse_induction.ll?rev=181286&view=auto">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/reverse_induction.ll?rev=181286&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/Transforms/LoopVectorize/reverse_induction.ll (added)<br>+++ llvm/trunk/test/Transforms/LoopVectorize/reverse_induction.ll Mon May  6 23:37:05 2013<br>@@ -0,0 +1,79 @@<br>+; RUN: opt < %s -loop-vectorize -force-vector-unroll=2 -force-vector-width=4 -S | FileCheck %s<br>+<br>+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"<br>+<br>+; Make sure consecutive vector generates correct negative indices.<br>+; PR15882<br>+<br>+; CHECK: reverse_induction_i64<br>+; CHECK: add <4 x i64> %[[SPLAT:.*]], <i64 0, i64 -1, i64 -2, i64 -3><br>+; CHECK: add <4 x i64> %[[SPLAT]], <i64 -4, i64 -5, i64 -6, i64 -7><br>+<br>+define i32 @reverse_induction_i64(i64 %startval, i32 * %ptr) {<br>+entry:<br>+  br label %for.body<br>+<br>+for.body:<br>+  %add.i7 = phi i64 [ %startval, %entry ], [ %add.i, %for.body ]<br>+  %i.06 = phi i32 [ 0, %entry ], [ %inc4, %for.body ]<br>+  %redux5 = phi i32 [ 0, %entry ], [ %inc.redux, %for.body ]<br>+  %add.i = add i64 %add.i7, -1<br>+  %kind_.i = getelementptr inbounds i32* %ptr, i64 %add.i<br>+  %tmp.i1 = load i32* %kind_.i, align 4<br>+  %inc.redux = add i32 %tmp.i1, %redux5<br>+  %inc4 = add i32 %i.06, 1<br>+  %exitcond = icmp ne i32 %inc4, 1024<br>+  br i1 %exitcond, label %for.body, label %loopend<br>+<br>+loopend:<br>+  ret i32 %inc.redux<br>+}<br>+<br>+; CHECK: reverse_induction_i128<br>+; CHECK: add <4 x i128> %[[SPLAT:.*]], <i128 0, i128 -1, i128 -2, i128 -3><br>+; CHECK: add <4 x i128> %[[SPLAT]], <i128 -4, i128 -5, i128 -6, i128 -7><br>+define i32 @reverse_induction_i128(i128 %startval, i32 * %ptr) {<br>+entry:<br>+  br label %for.body<br>+<br>+for.body:<br>+  %add.i7 = phi i128 [ %startval, %entry ], [ %add.i, %for.body ]<br>+  %i.06 = phi i32 [ 0, %entry ], [ %inc4, %for.body ]<br>+  %redux5 = phi i32 [ 0, %entry ], [ %inc.redux, %for.body ]<br>+  %add.i = add i128 %add.i7, -1<br>+  %kind_.i = getelementptr inbounds i32* %ptr, i128 %add.i<br>+  %tmp.i1 = load i32* %kind_.i, align 4<br>+  %inc.redux = add i32 %tmp.i1, %redux5<br>+  %inc4 = add i32 %i.06, 1<br>+  %exitcond = icmp ne i32 %inc4, 1024<br>+  br i1 %exitcond, label %for.body, label %loopend<br>+<br>+loopend:<br>+  ret i32 %inc.redux<br>+}<br>+<br>+; CHECK: reverse_induction_i16<br>+; CHECK: add <4 x i16> %[[SPLAT:.*]], <i16 0, i16 -1, i16 -2, i16 -3><br>+; CHECK: add <4 x i16> %[[SPLAT]], <i16 -4, i16 -5, i16 -6, i16 -7><br>+<br>+define i32 @reverse_induction_i16(i16 %startval, i32 * %ptr) {<br>+entry:<br>+  br label %for.body<br>+<br>+for.body:<br>+  %add.i7 = phi i16 [ %startval, %entry ], [ %add.i, %for.body ]<br>+  %i.06 = phi i32 [ 0, %entry ], [ %inc4, %for.body ]<br>+  %redux5 = phi i32 [ 0, %entry ], [ %inc.redux, %for.body ]<br>+  %add.i = add i16 %add.i7, -1<br>+  %kind_.i = getelementptr inbounds i32* %ptr, i16 %add.i<br>+  %tmp.i1 = load i32* %kind_.i, align 4<br>+  %inc.redux = add i32 %tmp.i1, %redux5<br>+  %inc4 = add i32 %i.06, 1<br>+  %exitcond = icmp ne i32 %inc4, 1024<br>+  br i1 %exitcond, label %for.body, label %loopend<br>+<br>+loopend:<br>+  ret i32 %inc.redux<br>+}<br>+<br>+<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</blockquote></blockquote></div></blockquote></div><br></div></body></html>