OSDN Git Service

X86DAGToDAGISel::matchBitExtract(): lambdas can't have default arguments.
authorRoman Lebedev <lebedev.ri@gmail.com>
Tue, 23 Oct 2018 18:27:10 +0000 (18:27 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Tue, 23 Oct 2018 18:27:10 +0000 (18:27 +0000)
As reported by ctopper.
That is a gcc-only warning at the moment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345065 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelDAGToDAG.cpp

index 73abdd8..4b803c5 100644 (file)
@@ -2709,10 +2709,12 @@ bool X86DAGToDAGISel::matchBitExtract(SDNode *Node) {
   // If we have BMI2's BZHI, we are ok with muti-use patterns.
   // Else, if we only have BMI1's BEXTR, we require one-use.
   const bool CanHaveExtraUses = Subtarget->hasBMI2();
-  auto checkOneUse = [CanHaveExtraUses](SDValue Op, unsigned NUses = 1) {
+  auto checkUses = [CanHaveExtraUses](SDValue Op, unsigned NUses) {
     return CanHaveExtraUses ||
            Op.getNode()->hasNUsesOfValue(NUses, Op.getResNo());
   };
+  auto checkOneUse = [checkUses](SDValue Op) { return checkUses(Op, 1); };
+  auto checkTwoUse = [checkUses](SDValue Op) { return checkUses(Op, 2); };
 
   // a) x & ((1 << nbits) + (-1))
   auto matchPatternA = [&checkOneUse, &NBits](SDValue Mask) -> bool {
@@ -2750,7 +2752,8 @@ bool X86DAGToDAGISel::matchBitExtract(SDNode *Node) {
   SDValue X;
 
   // d) x << (32 - y) >> (32 - y)
-  auto matchPatternD = [&checkOneUse, Size, &X, &NBits](SDNode *Node) -> bool {
+  auto matchPatternD = [&checkOneUse, &checkTwoUse, Size, &X,
+                        &NBits](SDNode *Node) -> bool {
     if (Node->getOpcode() != ISD::SRL)
       return false;
     SDValue N0 = Node->getOperand(0);
@@ -2760,7 +2763,7 @@ bool X86DAGToDAGISel::matchBitExtract(SDNode *Node) {
     SDValue N01 = N0->getOperand(1);
     // Both of the shifts must be by the exact same value.
     // There should not be any uses of the shift amount outside of the pattern.
-    if (N1 != N01 || !checkOneUse(N1, 2))
+    if (N1 != N01 || !checkTwoUse(N1))
       return false;
     // Skip over a truncate of the shift amount.
     if (N1->getOpcode() == ISD::TRUNCATE) {