================
@@ -503,6 +503,48 @@ Instruction *InstCombinerImpl::foldSelectOpOp(SelectInst 
&SI, Instruction *TI,
   return nullptr;
 }
 
+/// select C, f(..., X, ...), f(..., Y, ...) --> f(..., select C, X, Y, ...)
+static Instruction *
+foldSelectIntoIntrinsicArg(SelectInst &SI, IntrinsicInst *TII,
+                           IntrinsicInst *FII,
+                           InstCombiner::BuilderTy &Builder) {
+  if (TII->getCalledFunction() != FII->getCalledFunction())
+    return nullptr;
+
+  std::optional<unsigned> DiffArgNo;
+  for (unsigned I = 0, E = TII->arg_size(); I != E; ++I) {
+    if (TII->getArgOperand(I) == FII->getArgOperand(I))
+      continue;
+    if (DiffArgNo)
+      return nullptr;
+    DiffArgNo = I;
+  }
+  if (!DiffArgNo)
+    return nullptr;
+
+  // A select cannot feed a parameter that requires an immediate.
+  if (TII->paramHasAttr(*DiffArgNo, Attribute::ImmArg))
----------------
harrisonGPU wrote:

Updated.

https://github.com/llvm/llvm-project/pull/227737
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to