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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 03:29:04 PDT 2024


================
@@ -9924,15 +9924,8 @@ SDValue SelectionDAG::simplifySelect(SDValue Cond, SDValue T, SDValue F) {
 
   // select true, T, F --> T
   // select false, T, F --> F
-  if (auto *CondC = dyn_cast<ConstantSDNode>(Cond))
-    return CondC->isZero() ? F : T;
-
-  // TODO: This should simplify VSELECT with non-zero constant condition using
-  // something like this (but check boolean contents to be complete?):
-  if (ConstantSDNode *CondC = isConstOrConstSplat(Cond, /*AllowUndefs*/ false,
-                                                  /*AllowTruncation*/ true))
-    if (CondC->isZero())
-      return F;
+  if (auto CondC = isBoolConstant(Cond, /*AllowTruncation*/ true))
----------------
arsenm wrote:

```suggestion
  if (auto CondC = isBoolConstant(Cond, /*AllowTruncation=*/ true))
```

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


More information about the llvm-commits mailing list