[llvm] [X86] Attempt to fold extract_vector_elt(logicop(x,y),i) -> extract_vector_elt(x,i) (PR #194581)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 07:27:30 PDT 2026


================
@@ -7767,6 +7767,13 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
         }
       }
     }
+    // Logic ops can be folded from raw integer bits - mainly for AVX512 masks.
+    if (ISD::isBitwiseLogicOp(Opcode) && isa<ConstantSDNode>(N1) &&
+        isa<ConstantSDNode>(N2)) {
+      if (SDValue Res = FoldConstantArithmetic(Opcode, DL, N1.getValueType(),
----------------
phoebewang wrote:

Why we fold it here? I think the general DAGCombiner would do it already.

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


More information about the llvm-commits mailing list