[llvm] [X86][CodeGen] Support hoisting load/store with conditional faulting (PR #96720)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 00:59:19 PDT 2024


================
@@ -55633,6 +55684,36 @@ static SDValue combineSubSetcc(SDNode *N, SelectionDAG &DAG) {
   return SDValue();
 }
 
+static SDValue combineX86CloadCstore(SDNode *N, SelectionDAG &DAG) {
+  // res, flags2 = sub 0, (setcc cc, flag)
+  // cload/cstore ..., cond_ne, flag2
+  // ->
+  // cload/cstore cc, flag
+  //
+  // if res has no users, where op is cload/cstore.
+  if (N->getConstantOperandVal(3) != X86::COND_NE)
+    return SDValue();
+
+  SDNode *Sub = N->getOperand(4).getNode();
+  if (Sub->getOpcode() != X86ISD::SUB)
+    return SDValue();
+
+  SDValue Op1 = Sub->getOperand(1);
+
+  if (Sub->hasAnyUseOfValue(0) || !X86::isZeroNode(Sub->getOperand(0)) ||
----------------
KanRobert wrote:

I think we don't need to. If `flag2` has other users, the sub will be kept.
Here we let the cload/cstore use `flag` instead of `flag2` reduces the data dependency even if the sub is not removed.


https://github.com/llvm/llvm-project/pull/96720


More information about the llvm-commits mailing list