[llvm] [X86] Drop instruction prefetch with unsupported operands in LowerPREFETCH (PR #225826)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 06:07:12 PDT 2026


================
@@ -34583,10 +34583,15 @@ static SDValue LowerCVTPS2PH(SDValue Op, SelectionDAG &DAG) {
 static SDValue LowerPREFETCH(SDValue Op, const X86Subtarget &Subtarget,
                              SelectionDAG &DAG) {
   unsigned IsData = Op.getConstantOperandVal(4);
-
-  // We don't support non-data prefetch without PREFETCHI.
-  // Just preserve the chain.
-  if (!IsData && !Subtarget.hasPREFETCHI())
+  unsigned RW = Op.getConstantOperandVal(2);
+  unsigned Locality = Op.getConstantOperandVal(3);
+
+  // PREFETCHI only supports instruction read prefetch with T0 (locality 3)
+  // or T1 (locality 2) hints in 64-bit mode. If PREFETCHI is not supported,
+  // or if the instruction prefetch is a write or has locality not in {2, 3},
+  // drop it and preserve the chain.
+  if (!IsData && (!Subtarget.hasPREFETCHI() || !Subtarget.is64Bit() ||
----------------
RKSimon wrote:

Do we have test coverage for when PREFETCHI capable targets are run on 32-bit triples?

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


More information about the llvm-commits mailing list