<div dir="ltr"><div dir="ltr"><div dir="ltr">I am seeing crashes that bisect cleanly to this revision.<div><br></div><div>This is the crash reported by llc:</div><div><br></div><div><div>$ ./llc testcase-reduced.ll -o /dev/null</div><div>Stack dump:</div><div>0.<span style="white-space:pre">        </span>Program arguments: ./llc testcase-reduced.ll -o /dev/null </div><div>1.<span style="white-space:pre"> </span>Running pass 'Function Pass Manager' on module 'testcase-reduced.ll'.</div><div>2.<span style="white-space:pre">       </span>Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on function '@f'</div><div>0  llc             0x00005599bdc0bb38</div><div>1  llc             0x00005599bdc0e3e6</div><div>2  libpthread.so.0 0x00007f6114bb49a0</div><div>3  llc             0x00005599bd43e595</div></div><div><br></div><div><br></div><div>This looks to me like it may simply be a latent bug exposed by this revision. It does bisect cleanly to this revision, though, so I'm going to go ahead and revert as a temporary, stopgap measure.</div><div><br></div><div>Below is a fairly reduced test case (use the same command as above ^^^). It crashes under llc as new as r359636, but works if I revert just this revision.</div><div><br></div><div>I hope that the test base below is enough to make progress. Sorry about the revert. :-(</div><div><br></div><div>--dlj</div><div><br></div><div><br></div><div><br></div><div><br></div><div><div>$ cat testcase-reduced.ll</div><div>source_filename = "375b79.cpp"</div><div>target datalayout = "e-m:e-i64:64-n32:64"</div><div>target triple = "powerpc64le-unknown-linux-gnu"</div><div><br></div><div>define void @f() local_unnamed_addr #0 align 32 {</div><div>  br i1 undef, label %1, label %23</div><div><br></div><div>1:                                                ; preds = %0</div><div>  br i1 undef, label %24, label %2</div><div><br></div><div>2:                                                ; preds = %1</div><div>  br label %3</div><div><br></div><div>3:                                                ; preds = %3, %2</div><div>  %4 = phi <2 x i64> [ zeroinitializer, %2 ], [ %17, %3 ]</div><div>  %5 = phi <2 x i64> [ zeroinitializer, %2 ], [ %18, %3 ]</div><div>  %6 = load <2 x i32>, <2 x i32>* undef, align 4</div><div>  %7 = ashr <2 x i32> %6, <i32 31, i32 31></div><div>  %8 = xor <2 x i32> zeroinitializer, %7</div><div>  %9 = or <2 x i32> %8, <i32 1, i32 1></div><div>  %10 = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %9, i1 true)</div><div>  %11 = xor <2 x i32> %10, <i32 31, i32 31></div><div>  %12 = mul nuw nsw <2 x i32> %11, <i32 9, i32 9></div><div>  %13 = add nuw nsw <2 x i32> %12, <i32 73, i32 73></div><div>  %14 = lshr <2 x i32> %13, <i32 6, i32 6></div><div>  %15 = zext <2 x i32> undef to <2 x i64></div><div>  %16 = zext <2 x i32> %14 to <2 x i64></div><div>  %17 = add <2 x i64> %4, %15</div><div>  %18 = add <2 x i64> %5, %16</div><div>  %19 = add i64 0, 24</div><div>  br i1 false, label %20, label %3, !llvm.loop !1</div><div><br></div><div>20:                                               ; preds = %3</div><div>  %21 = add <2 x i64> %18, %17</div><div>  %22 = add <2 x i64> undef, %21</div><div>  br i1 undef, label %23, label %24</div><div><br></div><div>23:                                               ; preds = %24, %20, %0</div><div>  ret void</div><div><br></div><div>24:                                               ; preds = %24, %20, %1</div><div>  br i1 undef, label %23, label %24, !llvm.loop !3</div><div>}</div><div><br></div><div>; Function Attrs: nounwind readnone speculatable</div><div>declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1 immarg) #1</div><div><br></div><div>attributes #0 = { "use-soft-float"="false" }</div><div>attributes #1 = { nounwind readnone speculatable }</div><div><br></div><div>!llvm.ident = !{!0}</div><div><br></div><div>!0 = !{!"clang version eleventeen (trunk)"}</div><div>!1 = distinct !{!1, !2}</div><div>!2 = !{!"llvm.loop.isvectorized", i32 1}</div><div>!3 = distinct !{!3, !4, !2}</div><div>!4 = !{!"llvm.loop.unroll.runtime.disable"}</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 26, 2019 at 9:12 AM Roland Froese via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: froese<br>
Date: Fri Apr 26 09:14:17 2019<br>
New Revision: 359313<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=359313&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=359313&view=rev</a><br>
Log:<br>
[PowerPC] Update P9 vector costs for insert/extract element<br>
<br>
The PPC vector cost model values for insert/extract element reflect older<br>
processors that lacked vector insert/extract and move-to/move-from VSR<br>
instructions.  Update getVectorInstrCost to give appropriate values for when<br>
the newer instructions are present.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D60160" rel="noreferrer" target="_blank">https://reviews.llvm.org/D60160</a><br>
<br>
Modified:<br>
    llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp<br>
    llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll<br>
<br>
Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp?rev=359313&r1=359312&r2=359313&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp?rev=359313&r1=359312&r2=359313&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp (original)<br>
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp Fri Apr 26 09:14:17 2019<br>
@@ -412,6 +412,35 @@ int PPCTTIImpl::getVectorInstrCost(unsig<br>
       return 0;<br>
<br>
     return Cost;<br>
+<br>
+  } else if (Val->getScalarType()->isIntegerTy() && Index != -1U) {<br>
+    if (ST->hasP9Altivec()) {<br>
+      if (ISD == ISD::INSERT_VECTOR_ELT)<br>
+        // A move-to VSR and a permute/insert.  Assume vector operation cost<br>
+        // for both (cost will be 2x on P9).<br>
+        return vectorCostAdjustment(2, Opcode, Val, nullptr);<br>
+<br>
+      // It's an extract.  Maybe we can do a cheap move-from VSR.<br>
+      unsigned EltSize = Val->getScalarSizeInBits();<br>
+      if (EltSize == 64) {<br>
+        unsigned MfvsrdIndex = ST->isLittleEndian() ? 1 : 0;<br>
+        if (Index == MfvsrdIndex)<br>
+          return 1;<br>
+      } else if (EltSize == 32) {<br>
+        unsigned MfvsrwzIndex = ST->isLittleEndian() ? 2 : 1;<br>
+        if (Index == MfvsrwzIndex)<br>
+          return 1;<br>
+      }<br>
+<br>
+      // We need a vector extract (or mfvsrld).  Assume vector operation cost.<br>
+      // The cost of the load constant for a vector extract is disregarded<br>
+      // (invariant, easily schedulable).<br>
+      return vectorCostAdjustment(1, Opcode, Val, nullptr);<br>
+      <br>
+    } else if (ST->hasDirectMove())<br>
+      // Assume permute has standard cost.<br>
+      // Assume move-to/move-from VSR have 2x standard cost.<br>
+      return 3;<br>
   }<br>
<br>
   // Estimated cost of a load-hit-store delay.  This was obtained<br>
<br>
Modified: llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll?rev=359313&r1=359312&r2=359313&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll?rev=359313&r1=359312&r2=359313&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll (original)<br>
+++ llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll Fri Apr 26 09:14:17 2019<br>
@@ -14,15 +14,15 @@ define i32 @insert(i32 %arg) {<br>
 ; CHECK-P7-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef<br>
 ;<br>
 ; CHECK-P8LE-LABEL: 'insert'<br>
-; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
+; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
 ; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef<br>
 ;<br>
 ; CHECK-P9BE-LABEL: 'insert'<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
 ; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef<br>
 ;<br>
 ; CHECK-P9LE-LABEL: 'insert'<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
 ; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 undef<br>
 ;<br>
   %x = insertelement <4 x i32> undef, i32 %arg, i32 0<br>
@@ -40,11 +40,11 @@ define i32 @extract(<4 x i32> %arg) {<br>
 ; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x<br>
 ;<br>
 ; CHECK-P9BE-LABEL: 'extract'<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %x = extractelement <4 x i32> %arg, i32 0<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %x = extractelement <4 x i32> %arg, i32 0<br>
 ; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x<br>
 ;<br>
 ; CHECK-P9LE-LABEL: 'extract'<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %x = extractelement <4 x i32> %arg, i32 0<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %x = extractelement <4 x i32> %arg, i32 0<br>
 ; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %x<br>
 ;<br>
   %x = extractelement <4 x i32> %arg, i32 0<br>
@@ -83,15 +83,15 @@ define void @test4xi32(<4 x i32> %v1, i3<br>
 ; CHECK-P7-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P8LE-LABEL: 'test4xi32'<br>
-; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
+; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
 ; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9BE-LABEL: 'test4xi32'<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
 ; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9LE-LABEL: 'test4xi32'<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 11 for instruction: %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
 ; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
   %v2 = insertelement <4 x i32> %v1, i32 %x1, i32 2<br>
@@ -114,17 +114,17 @@ define void @vexti32(<4 x i32> %p1) {<br>
 ; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9BE-LABEL: 'vexti32'<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i1 = extractelement <4 x i32> %p1, i32 0<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i2 = extractelement <4 x i32> %p1, i32 1<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i3 = extractelement <4 x i32> %p1, i32 2<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i4 = extractelement <4 x i32> %p1, i32 3<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <4 x i32> %p1, i32 0<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %i2 = extractelement <4 x i32> %p1, i32 1<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i3 = extractelement <4 x i32> %p1, i32 2<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i4 = extractelement <4 x i32> %p1, i32 3<br>
 ; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9LE-LABEL: 'vexti32'<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i1 = extractelement <4 x i32> %p1, i32 0<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i2 = extractelement <4 x i32> %p1, i32 1<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i3 = extractelement <4 x i32> %p1, i32 2<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i4 = extractelement <4 x i32> %p1, i32 3<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <4 x i32> %p1, i32 0<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i2 = extractelement <4 x i32> %p1, i32 1<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %i3 = extractelement <4 x i32> %p1, i32 2<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i4 = extractelement <4 x i32> %p1, i32 3<br>
 ; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
   %i1 = extractelement <4 x i32> %p1, i32 0<br>
@@ -146,13 +146,13 @@ define void @vexti64(<2 x i64> %p1) {<br>
 ; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9BE-LABEL: 'vexti64'<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1<br>
 ; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9LE-LABEL: 'vexti64'<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <2 x i64> %p1, i32 0<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %i2 = extractelement <2 x i64> %p1, i32 1<br>
 ; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
   %i1 = extractelement <2 x i64> %p1, i32 0<br>
@@ -172,13 +172,13 @@ define void @vext(<8 x i16> %p1, <16 x i<br>
 ; CHECK-P8LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9BE-LABEL: 'vext'<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i1 = extractelement <8 x i16> %p1, i32 0<br>
-; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i2 = extractelement <16 x i8> %p2, i32 0<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <8 x i16> %p1, i32 0<br>
+; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i2 = extractelement <16 x i8> %p2, i32 0<br>
 ; CHECK-P9BE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
 ; CHECK-P9LE-LABEL: 'vext'<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i1 = extractelement <8 x i16> %p1, i32 0<br>
-; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %i2 = extractelement <16 x i8> %p2, i32 0<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i1 = extractelement <8 x i16> %p1, i32 0<br>
+; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %i2 = extractelement <16 x i8> %p2, i32 0<br>
 ; CHECK-P9LE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret void<br>
 ;<br>
   %i1 = extractelement <8 x i16> %p1, i32 0<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>