[llvm] Reapply "[DAGCombiner] Add support for scalarising extracts of a vector setcc (#117566)" (PR #118823)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 04:25:50 PST 2024


================
@@ -3316,6 +3317,22 @@ static std::pair<ISD::CondCode, ISD::NodeType> getExpandedMinMaxOps(int Op) {
   }
 }
 
+void DAGTypeLegalizer::ExpandIntRes_SETCC(SDNode *N, SDValue &Lo, SDValue &Hi) {
+  SDLoc DL(N);
+
+  SDValue LHS = N->getOperand(0);
+  SDValue RHS = N->getOperand(1);
+  EVT NewVT = getSetCCResultType(LHS.getValueType());
+
+  // Taking the same approach as ScalarizeVecRes_SETCC
+  SDValue Res = DAG.getNode(ISD::SETCC, DL, NewVT, LHS, RHS, N->getOperand(2));
+
+  ISD::NodeType ExtendCode =
+      TargetLowering::getExtendForContent(TLI.getBooleanContents(NewVT));
+  Res = DAG.getExtOrTrunc(Res, DL, N->getValueType(0), ExtendCode);
----------------
paulwalker-arm wrote:

```suggestion
  Res = DAG.getBoolExtOrTrunc(Res, DL, N->getValueType(0), NewVT);
```

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


More information about the llvm-commits mailing list