[llvm] [X86][EVEX512] Do not allow 512-bit memcpy without EVEX512 (PR #70420)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 26 23:33:48 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Phoebe Wang (phoebewang)
<details>
<summary>Changes</summary>
Solves crash mentioned in #<!-- -->65920.
---
Full diff: https://github.com/llvm/llvm-project/pull/70420.diff
2 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLoweringCall.cpp (+2-2)
- (added) llvm/test/CodeGen/X86/evex512-mem.ll (+29)
``````````diff
diff --git a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
index c47ddae072b4fe8..2fe145f9267de87 100644
--- a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
+++ b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
@@ -281,7 +281,7 @@ EVT X86TargetLowering::getOptimalMemOpType(
if (Op.size() >= 16 &&
(!Subtarget.isUnalignedMem16Slow() || Op.isAligned(Align(16)))) {
// FIXME: Check if unaligned 64-byte accesses are slow.
- if (Op.size() >= 64 && Subtarget.hasAVX512() &&
+ if (Op.size() >= 64 && Subtarget.hasAVX512() && Subtarget.hasEVEX512() &&
(Subtarget.getPreferVectorWidth() >= 512)) {
return Subtarget.hasBWI() ? MVT::v64i8 : MVT::v16i32;
}
@@ -395,7 +395,7 @@ bool X86TargetLowering::allowsMemoryAccess(LLVMContext &Context,
return true;
return false;
case 512:
- if (Subtarget.hasAVX512())
+ if (Subtarget.hasAVX512() && Subtarget.hasEVEX512())
return true;
return false;
default:
diff --git a/llvm/test/CodeGen/X86/evex512-mem.ll b/llvm/test/CodeGen/X86/evex512-mem.ll
new file mode 100644
index 000000000000000..a900d0837c1baa3
--- /dev/null
+++ b/llvm/test/CodeGen/X86/evex512-mem.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=x86_64-apple-darwin -mattr=avx512f,avx512bw,avx512vl < %s | FileCheck %s --check-prefix=AVX512
+; RUN: llc -mtriple=x86_64-apple-darwin -mattr=avx512f,avx512bw,avx512vl,-evex512 < %s | FileCheck %s --check-prefix=AVX256
+
+define void @test1() {
+; AVX512-LABEL: test1:
+; AVX512: ## %bb.0:
+; AVX512-NEXT: movq 64, %rax
+; AVX512-NEXT: movq %rax, (%rax)
+; AVX512-NEXT: vmovups 0, %zmm0
+; AVX512-NEXT: vmovups %zmm0, (%rax)
+; AVX512-NEXT: vzeroupper
+; AVX512-NEXT: retq
+;
+; AVX256-LABEL: test1:
+; AVX256: ## %bb.0:
+; AVX256-NEXT: movq 64, %rax
+; AVX256-NEXT: movq %rax, (%rax)
+; AVX256-NEXT: vmovups 0, %ymm0
+; AVX256-NEXT: vmovups 32, %ymm1
+; AVX256-NEXT: vmovups %ymm1, (%rax)
+; AVX256-NEXT: vmovups %ymm0, (%rax)
+; AVX256-NEXT: vzeroupper
+; AVX256-NEXT: retq
+ call void @llvm.memcpy.p0.p0.i64(ptr align 8 poison, ptr align 8 null, i64 72, i1 false)
+ ret void
+}
+
+declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
``````````
</details>
https://github.com/llvm/llvm-project/pull/70420
More information about the llvm-commits
mailing list