[llvm-branch-commits] [llvm-branch] r355310 - Merging r355116 and r355117:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 4 04:41:40 PST 2019


Author: hans
Date: Mon Mar  4 04:41:39 2019
New Revision: 355310

URL: http://llvm.org/viewvc/llvm-project?rev=355310&view=rev
Log:
Merging r355116 and r355117:

------------------------------------------------------------------------
r355116 | ctopper | 2019-02-28 19:49:29 +0100 (Thu, 28 Feb 2019) | 7 lines

[X86] Don't peek through bitcasts before checking ISD::isBuildVectorOfConstantSDNodes in combineTruncatedArithmetic

We don't have any combines that can look through a bitcast to truncate a build vector of constants. So the truncate will stick around and give us something like this pattern (binop (trunc X), (trunc (bitcast (build_vector)))) which has two truncates in it. Which will be reversed by hoistLogicOpWithSameOpcodeHands in the generic DAG combiner. Thus causing an infinite loop.

Even if we had a combine for (truncate (bitcast (build_vector))), I think it would need to be implemented in getNode otherwise DAG combiner visit ordering would probably still visit the binop first and reverse it. Or combineTruncatedArithmetic would need to do its own constant folding.

Differential Revision: https://reviews.llvm.org/D58705
------------------------------------------------------------------------

------------------------------------------------------------------------
r355117 | ctopper | 2019-02-28 19:50:16 +0100 (Thu, 28 Feb 2019) | 1 line

[X86] Add test case that was supposed to go with r355116.
------------------------------------------------------------------------

Added:
    llvm/branches/release_80/test/CodeGen/X86/pr40891.ll
      - copied, changed from r355117, llvm/trunk/test/CodeGen/X86/pr40891.ll
Modified:
    llvm/branches/release_80/   (props changed)
    llvm/branches/release_80/lib/Target/X86/X86ISelLowering.cpp

Propchange: llvm/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Mar  4 04:41:39 2019
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,351322,351325,351344-351345,351349,351351,351370,351381,351387,351421,351426,351436,351475,351485,351753-351754,351765,351910,351930,351932,352034,352204,352246,352374,352555,352607-352608,352707,352714,352770,352886,352889,352892,352895,352908,352917,352935,352945,353015,353061,353082,353138,353141,353155,353213,353218,353304,353308,353334,353367,353374,353383,353463,353480,353489,353551,353733,353758,353809,353907,354034,354117,354128,354131,354144,354207,354497,354505,354733,354756,354764
+/llvm/trunk:155241,351322,351325,351344-351345,351349,351351,351370,351381,351387,351421,351426,351436,351475,351485,351753-351754,351765,351910,351930,351932,352034,352204,352246,352374,352555,352607-352608,352707,352714,352770,352886,352889,352892,352895,352908,352917,352935,352945,353015,353061,353082,353138,353141,353155,353213,353218,353304,353308,353334,353367,353374,353383,353463,353480,353489,353551,353733,353758,353809,353907,354034,354117,354128,354131,354144,354207,354497,354505,354733,354756,354764,355116-355117

Modified: llvm/branches/release_80/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/lib/Target/X86/X86ISelLowering.cpp?rev=355310&r1=355309&r2=355310&view=diff
==============================================================================
--- llvm/branches/release_80/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/branches/release_80/lib/Target/X86/X86ISelLowering.cpp Mon Mar  4 04:41:39 2019
@@ -38134,8 +38134,11 @@ static SDValue combineTruncatedArithmeti
       return true;
 
     // See if this is a single use constant which can be constant folded.
-    SDValue BC = peekThroughOneUseBitcasts(Op);
-    return ISD::isBuildVectorOfConstantSDNodes(BC.getNode());
+    // NOTE: We don't peek throught bitcasts here because there is currently
+    // no support for constant folding truncate+bitcast+vector_of_constants. So
+    // we'll just send up with a truncate on both operands which will
+    // get turned back into (truncate (binop)) causing an infinite loop.
+    return ISD::isBuildVectorOfConstantSDNodes(Op.getNode());
   };
 
   auto TruncateArithmetic = [&](SDValue N0, SDValue N1) {

Copied: llvm/branches/release_80/test/CodeGen/X86/pr40891.ll (from r355117, llvm/trunk/test/CodeGen/X86/pr40891.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_80/test/CodeGen/X86/pr40891.ll?p2=llvm/branches/release_80/test/CodeGen/X86/pr40891.ll&p1=llvm/trunk/test/CodeGen/X86/pr40891.ll&r1=355117&r2=355310&rev=355310&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr40891.ll (original)
+++ llvm/branches/release_80/test/CodeGen/X86/pr40891.ll Mon Mar  4 04:41:39 2019
@@ -8,10 +8,10 @@ define <8 x i32> @foo(<8 x i64> %x, <4 x
 ; CHECK:       # %bb.0:
 ; CHECK-NEXT:    vandps %ymm2, %ymm0, %ymm0
 ; CHECK-NEXT:    vandps {{\.LCPI.*}}, %ymm1, %ymm1
-; CHECK-NEXT:    vextractf128 $1, %ymm0, %xmm2
-; CHECK-NEXT:    vshufps {{.*#+}} xmm0 = xmm0[0,2],xmm2[0,2]
-; CHECK-NEXT:    vextractf128 $1, %ymm1, %xmm2
-; CHECK-NEXT:    vshufps {{.*#+}} xmm1 = xmm1[0,2],xmm2[0,2]
+; CHECK-NEXT:    vpermilps {{.*#+}} ymm0 = ymm0[0,2,2,3,4,6,6,7]
+; CHECK-NEXT:    vpermpd {{.*#+}} ymm0 = ymm0[0,2,2,3]
+; CHECK-NEXT:    vpermilps {{.*#+}} ymm1 = ymm1[0,2,2,3,4,6,6,7]
+; CHECK-NEXT:    vpermpd {{.*#+}} ymm1 = ymm1[0,2,2,3]
 ; CHECK-NEXT:    vinsertf128 $1, %xmm1, %ymm0, %ymm0
 ; CHECK-NEXT:    retl
   %a = shufflevector <4 x i64> %y, <4 x i64> <i64 12345, i64 67890, i64 13579, i64 24680>, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>




More information about the llvm-branch-commits mailing list