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

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 06:29:51 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:

It might be safer if we only accept the 'clean' 1/0, -1/0 and 1b/0b T/F values and std::nullopt otherwise.

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


More information about the llvm-commits mailing list