[PATCH] D151050: [X86] Don't crash on instruction prefetch intrinsics without PREFETCHI support.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 21:31:47 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG022aefa59c28: [X86] Don't crash on instruction prefetch intrinsics without PREFETCHI support. (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151050/new/
https://reviews.llvm.org/D151050
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/prefetchi.ll
Index: llvm/test/CodeGen/X86/prefetchi.ll
===================================================================
--- llvm/test/CodeGen/X86/prefetchi.ll
+++ llvm/test/CodeGen/X86/prefetchi.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-- -mattr=+prefetchi | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefix=NOPREFETCHI
define dso_local void @t(ptr %ptr) nounwind {
; CHECK-LABEL: t:
@@ -9,6 +10,10 @@
; CHECK-NEXT: prefetchit1 t(%rip)
; CHECK-NEXT: prefetchit0 ext(%rip)
; CHECK-NEXT: retq
+;
+; NOPREFETCHI-LABEL: t:
+; NOPREFETCHI: # %bb.0: # %entry
+; NOPREFETCHI-NEXT: retq
entry:
tail call void @llvm.prefetch(ptr %ptr, i32 0, i32 2, i32 0)
tail call void @llvm.prefetch(ptr %ptr, i32 0, i32 3, i32 0)
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -529,7 +529,7 @@
}
if (Subtarget.hasSSEPrefetch() || Subtarget.hasThreeDNow())
- setOperationAction(ISD::PREFETCH , MVT::Other, Legal);
+ setOperationAction(ISD::PREFETCH , MVT::Other, Custom);
setOperationAction(ISD::ATOMIC_FENCE , MVT::Other, Custom);
@@ -33984,6 +33984,18 @@
return DAG.getNode(ISD::CONCAT_VECTORS, dl, VT, Lo, Hi);
}
+static SDValue LowerPREFETCH(SDValue Op, const X86Subtarget &Subtarget,
+ SelectionDAG &DAG) {
+ unsigned IsData = cast<ConstantSDNode>(Op.getOperand(4))->getZExtValue();
+
+ // We don't support non-data prefetch without PREFETCHI.
+ // Just preserve the chain.
+ if (!IsData && !Subtarget.hasPREFETCHI())
+ return Op.getOperand(0);
+
+ return Op;
+}
+
static StringRef getInstrStrFromOpNo(const SmallVectorImpl<StringRef> &AsmStrs,
unsigned OpNo) {
const APInt Operand(32, OpNo);
@@ -34188,6 +34200,7 @@
case ISD::GC_TRANSITION_END: return LowerGC_TRANSITION(Op, DAG);
case ISD::ADDRSPACECAST: return LowerADDRSPACECAST(Op, DAG);
case X86ISD::CVTPS2PH: return LowerCVTPS2PH(Op, DAG);
+ case ISD::PREFETCH: return LowerPREFETCH(Op, Subtarget, DAG);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151050.524157.patch
Type: text/x-patch
Size: 2302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230522/c76cde39/attachment.bin>
More information about the llvm-commits
mailing list