[llvm] r252168 - [ARM] Compute known bits for ARMISD::CMOV

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 07:21:58 PST 2015


Author: jamesm
Date: Thu Nov  5 09:21:58 2015
New Revision: 252168

URL: http://llvm.org/viewvc/llvm-project?rev=252168&view=rev
Log:
[ARM] Compute known bits for ARMISD::CMOV

We can conservatively know that CMOV's known bits are the intersection of known bits for each of its operands. This helps PerformCMOVToBFICombine find more opportunities.

I tried hard to create a testcase for this and failed - we have to sufficiently confuse DAG.computeKnownBits which can see through all the cheap tricks I tried to narrow my larger testcase down :(

This code is actually exercised in CodeGen/ARM/bfi.ll, there's just no functional difference because DAG.computeKnownBits gets the right answer in that case.

Modified:
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=252168&r1=252167&r2=252168&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Nov  5 09:21:58 2015
@@ -10243,6 +10243,16 @@ static void computeKnownBits(SelectionDA
     KnownOne &= Mask;
     return;
   }
+  if (Op.getOpcode() == ARMISD::CMOV) {
+    APInt KZ2(KnownZero.getBitWidth(), 0);
+    APInt KO2(KnownOne.getBitWidth(), 0);
+    computeKnownBits(DAG, Op.getOperand(1), KnownZero, KnownOne);
+    computeKnownBits(DAG, Op.getOperand(2), KZ2, KO2);
+
+    KnownZero &= KZ2;
+    KnownOne &= KO2;
+    return;
+  }
   return DAG.computeKnownBits(Op, KnownZero, KnownOne);
 }
 




More information about the llvm-commits mailing list