[llvm] [SelectionDAG] Avoid unsafe scalarization of widened rotate extracts (PR #221165)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 00:00:08 PDT 2026


================
@@ -25586,8 +25589,14 @@ static SDValue scalarizeExtractedBinOp(SDNode *ExtElt, SelectionDAG &DAG,
     return SDValue();
 
   EVT ResVT = ExtElt->getValueType(0);
-  if (Opc == ISD::SETCC &&
-      (ResVT != Vec.getValueType().getVectorElementType() || LegalTypes))
+  EVT EltVT = Vec.getValueType().getVectorElementType();
+
+  // Rotates depend on the operand bit width. Moving the rotate after an extract
+  // that widens the element type would therefore change its semantics.
+  if (ResVT != EltVT && (Opc == ISD::ROTL || Opc == ISD::ROTR))
----------------
arsenm wrote:

Then shouldn't this function not have been called in the first place?

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


More information about the llvm-commits mailing list