<div dir="ltr">Reverted in r364876. I'm not sure which of Eric or myself is busier, but I'll also try to get a reproducer.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 28, 2019 at 6:32 PM Eric Christopher 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">Hi Roland,<br>
<br>
I'm seeing an instruction selection crash with this on some internal code:<br>
<br>
fatal error: error in backend: Cannot select: 0x7fffbabb30d0: v1i128 =<br>
smin 0x7fffbabb3000, 0x7fffbb233820<br>
  0x7fffbabb3000: v1i128 = smax 0x7fffbb233f08, 0x7fffbabb3958<br>
    0x7fffbb233f08: v1i128 = add nsw 0x7fffbabf4820, 0x7fffbabf4a90<br>
      0x7fffbabf4820: v1i128 = bitcast 0x7fffbb233138<br>
        0x7fffbb233138: v2i64 = BUILD_VECTOR 0x7fffbabf48f0, 0x7fffbb233750<br>
          0x7fffbabf48f0: i64 = extract_vector_elt 0x7fffbb233478,<br>
Constant:i64<0><br>
            0x7fffbb233478: v2i64,ch = CopyFromReg 0x7fffbb5c8058,<br>
Register:v2i64 %1<br>
              0x7fffbb233410: v2i64 = Register %1<br>
            0x7fffbb233068: i64 = Constant<0><br>
          0x7fffbb233750: i64 = sra 0x7fffbabf48f0, Constant:i32<63><br>
            0x7fffbabf48f0: i64 = extract_vector_elt 0x7fffbb233478,<br>
Constant:i64<0><br>
              0x7fffbb233478: v2i64,ch = CopyFromReg 0x7fffbb5c8058,<br>
Register:v2i64 %1<br>
                0x7fffbb233410: v2i64 = Register %1<br>
              0x7fffbb233068: i64 = Constant<0><br>
            0x7fffbb233a28: i32 = Constant<63><br>
      0x7fffbabf4a90: v1i128 = bitcast 0x7fffbb233af8<br>
        0x7fffbb233af8: v2i64 = BUILD_VECTOR 0x7fffbabf4958, 0x7fffbabf4750<br>
          0x7fffbabf4958: i64,ch = CopyFromReg 0x7fffbb5c8058, Register:i64 %3<br>
            0x7fffbb2333a8: i64 = Register %3<br>
          0x7fffbabf4750: i64 = sra 0x7fffbabf4958, Constant:i32<63><br>
            0x7fffbabf4958: i64,ch = CopyFromReg 0x7fffbb5c8058, Register:i64 %3<br>
              0x7fffbb2333a8: i64 = Register %3<br>
            0x7fffbb233a28: i32 = Constant<63><br>
    0x7fffbabb3958: v1i128 = bitcast 0x7fffbabb3618<br>
      0x7fffbabb3618: v4i32 = BUILD_VECTOR Constant:i32<0>,<br>
Constant:i32<0>, Constant:i32<0>, Constant:i32<0><br>
        0x7fffbb2338f0: i32 = Constant<0><br>
        0x7fffbb2338f0: i32 = Constant<0><br>
        0x7fffbb2338f0: i32 = Constant<0><br>
        0x7fffbb2338f0: i32 = Constant<0><br>
  0x7fffbb233820: v1i128 = bitcast 0x7fffbabf44e0<br>
    0x7fffbabf44e0: v2f64,ch = PPCISD::XXSWAPD 0x7fffbabf4a28:1, 0x7fffbabf4a28<br>
      0x7fffbabf4a28: v2f64,ch = PPCISD::LXVD2X<(load 16 from<br>
constant-pool)> 0x7fffbb5c8058, 0x7fffbb233340<br>
        0x7fffbb233340: i64,ch = PPCISD::TOC_ENTRY<(load 8 from got)><br>
TargetConstantPool:i64<<2 x i64> <i64 9223372036854775807, i64 0>> 0,<br>
Register:i64 $x2<br>
          0x7fffbabb3548: i64 = TargetConstantPool<<2 x i64> <i64<br>
9223372036854775807, i64 0>> 0<br>
          0x7fffbb2330d0: i64 = Register $x2<br>
<br>
Working on getting it reduced down so you've got a testcase, but I'd<br>
like to revert this in the mean time. FWIW once I get a testcase I<br>
probably will because it's already late on a Friday and you're OoO I'd<br>
imagine :)<br>
<br>
Thanks!<br>
<br>
-eric<br>
<br>
On Thu, Jun 27, 2019 at 9:20 AM Roland Froese via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: froese<br>
> Date: Thu Jun 27 09:20:24 2019<br>
> New Revision: 364557<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=364557&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=364557&view=rev</a><br>
> Log:<br>
> Recommit [PowerPC] Update P9 vector costs for insert/extract element<br>
><br>
> Recommit patch D60160 after regression fix patch D63463.<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=364557&r1=364556&r2=364557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp?rev=364557&r1=364556&r2=364557&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp (original)<br>
> +++ llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp Thu Jun 27 09:20:24 2019<br>
> @@ -752,6 +752,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=364557&r1=364556&r2=364557&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/PowerPC/insert_extract.ll?rev=364557&r1=364556&r2=364557&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 Thu Jun 27 09:20:24 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>
_______________________________________________<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>