<div dir="ltr">Hi Simon,<br><br>Thanks for this fix. I've tested it with the original failing random test and our builders are very happy :)<div><br></div><div>Cheers,</div><div><br></div><div>James</div></div><br><div class="gmail_quote">On Thu, 16 Apr 2015 at 09:29 Simon Pilgrim <<a href="mailto:llvm-dev@redking.me.uk">llvm-dev@redking.me.uk</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rksimon<br>
Date: Thu Apr 16 03:21:09 2015<br>
New Revision: 235079<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=235079&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=235079&view=rev</a><br>
Log:<br>
TRUNCATE constant folding - minor fix for rL233224<br>
<br>
Fix for test case found by James Molloy - TRUNCATE of constant build vectors can be more simply achieved by simply replacing with a new build vector node with the truncated value type - no need to touch the scalar operands at all.<br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/AArch64/fold-constants.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=235079&r1=235078&r2=235079&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=235079&r1=235078&r2=235079&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 16 03:21:09 2015<br>
@@ -2851,13 +2851,16 @@ SDValue SelectionDAG::getNode(unsigned O<br>
         // FIXME: Entirely reasonable to perform folding of other unary<br>
         // operations here as the need arises.<br>
         break;<br>
+      case ISD::TRUNCATE:<br>
+        // Constant build vector truncation can be done with the original scalar<br>
+        // operands but with a new build vector with the truncated value type.<br>
+        return getNode(ISD::BUILD_VECTOR, DL, VT, BV->ops());<br>
       case ISD::FNEG:<br>
       case ISD::FABS:<br>
       case ISD::FCEIL:<br>
       case ISD::FTRUNC:<br>
       case ISD::FFLOOR:<br>
       case ISD::FP_EXTEND:<br>
-      case ISD::TRUNCATE:<br>
       case ISD::UINT_TO_FP:<br>
       case ISD::SINT_TO_FP: {<br>
         // Let the above scalar folding handle the folding of each element.<br>
<br>
Added: llvm/trunk/test/CodeGen/AArch64/fold-constants.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fold-constants.ll?rev=235079&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/fold-constants.ll?rev=235079&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/AArch64/fold-constants.ll (added)<br>
+++ llvm/trunk/test/CodeGen/AArch64/fold-constants.ll Thu Apr 16 03:21:09 2015<br>
@@ -0,0 +1,21 @@<br>
+; RUN: llc -mtriple=aarch64-linux-gnu -o - %s | FileCheck %s<br>
+<br>
+define i64 @dotests_616() {<br>
+; CHECK-LABEL: dotests_616<br>
+; CHECK:       movi d0, #0000000000000000<br>
+; CHECK-NEXT:  umov w8, v0.b[2]<br>
+; CHECK-NEXT:  sbfx w8, w8, #0, #1<br>
+; CHECK-NEXT:  fmov s0, w8<br>
+; CHECK-NEXT:  fmov x0, d0<br>
+; CHECK-NEXT:  ret<br>
+entry:<br>
+  %0 = bitcast <2 x i64> zeroinitializer to <8 x i16><br>
+  %1 = and <8 x i16> zeroinitializer, %0<br>
+  %2 = icmp ne <8 x i16> %1, zeroinitializer<br>
+  %3 = extractelement <8 x i1> %2, i32 2<br>
+  %vgetq_lane285 = sext i1 %3 to i16<br>
+  %vset_lane = insertelement <4 x i16> undef, i16 %vgetq_lane285, i32 0<br>
+  %4 = bitcast <4 x i16> %vset_lane to <1 x i64><br>
+  %vget_lane = extractelement <1 x i64> %4, i32 0<br>
+  ret i64 %vget_lane<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>