[llvm] [SelectionDAG] Simplify vselect true, T, F -> T (PR #100992)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 04:19:38 PDT 2024


================
@@ -13138,6 +13117,23 @@ SDNode *SelectionDAG::isConstantFPBuildVectorOrConstantFP(SDValue N) const {
   return nullptr;
 }
 
+std::optional<bool> SelectionDAG::isBoolConstant(SDValue N,
+                                                 bool AllowTruncation) const {
+  ConstantSDNode *Const = isConstOrConstSplat(N, false, AllowTruncation);
+  if (!Const)
+    return std::nullopt;
+
+  switch (TLI->getBooleanContents(N.getValueType())) {
----------------
RKSimon wrote:

Thanks - an alternative would be an optional<bool> result that returns the exact match - which would mean we only need one call in simplifySelect. No strong preference on this one though tbh - as long as we only accept the 'clean' boolean contents values.

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


More information about the llvm-commits mailing list