[llvm] [X86][CodeGen] Support hoisting load/store with conditional faulting (PR #96720)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 00:19:12 PDT 2024


================
@@ -5891,14 +5917,21 @@ bool X86TTIImpl::canMacroFuseCmp() {
 }
 
 bool X86TTIImpl::isLegalMaskedLoad(Type *DataTy, Align Alignment) {
+  bool IsSingleElementVector =
+      isa<VectorType>(DataTy) &&
+      cast<FixedVectorType>(DataTy)->getNumElements() == 1;
+  Type *ScalarTy = DataTy->getScalarType();
+
+  if (ST->hasCF() && IsSingleElementVector &&
+      hasConditionalLoadStoreForType(ScalarTy))
+    return true;
+
   if (!ST->hasAVX())
     return false;
 
-  // The backend can't handle a single element vector.
-  if (isa<VectorType>(DataTy) &&
-      cast<FixedVectorType>(DataTy)->getNumElements() == 1)
+  // The backend can't handle a single element vector w/o CFCMOV.
+  if (IsSingleElementVector)
----------------
phoebewang wrote:

Why this cannot merge to line 5925? Doesn't it never handle `IsSingleElementVector = true`?

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


More information about the llvm-commits mailing list