[llvm] select (sext m), (add X, C), X --> (add X, (and C, (sext m)))) (PR #83640)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 17:13:32 PST 2024


================
@@ -12070,6 +12070,15 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
   if (SDValue F = extractBooleanFlip(N0, DAG, TLI, false))
     return DAG.getSelect(DL, VT, F, N2, N1);
 
+  // select (sext m), (add X, C), X --> (add X, (and C, (sext m))))
----------------
topperc wrote:

I think we need to check `TLI.getBooleanContents(N0.getValueType()) == TargetLowering::ZeroOrNegativeOneBooleanContent`. Otherwise there's no guarantee that `m` is all zeros or all ones.

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


More information about the llvm-commits mailing list