[llvm] [ConstantTime][LLVM] Add llvm.ct.select intrinsic with generic SelectionDAG lowering (PR #166702)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 15 13:39:01 PDT 2026


================
@@ -6888,6 +6888,15 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
     updateDAGForMaybeTailCall(MC);
     return;
   }
+  case Intrinsic::ct_select: {
+    // Fast-math flags on the call are intentionally dropped: CT_SELECT
+    // carries no SDNodeFlags, so no FMF-driven combine can apply to it.
+    SDValue Cond = getValue(I.getArgOperand(0));
+    SDValue A = getValue(I.getArgOperand(1));
+    SDValue B = getValue(I.getArgOperand(2));
+    setValue(&I, DAG.getCTSelect(getCurSDLoc(), A.getValueType(), Cond, A, B));
----------------
dtcxzyw wrote:

It may be DCEd in SDAG. If you don't want them to be dropped/reordered in SDAG, use `getRoot/setRoot` to model the side effect.



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


More information about the llvm-commits mailing list