diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td b/llvm/include/llvm/IR/IntrinsicsPowerPC.td --- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td +++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td @@ -1493,7 +1493,11 @@ def int_ppc_ttest : GCCBuiltin<"__builtin_ttest">, Intrinsic<[llvm_i64_ty], [], []>; -def int_ppc_cfence : Intrinsic<[], [llvm_anyint_ty], []>; +// We currently use llvm.ppc.cfence in the context of atomic load which +// in LLVM IR requires its type to be one of integer, pointer and +// float point type. So llvm_any_ty here refers to type mentioned above. +// Backend is supposed to lower these types to appropriate MVTs. +def int_ppc_cfence : Intrinsic<[], [llvm_any_ty], []>; // PowerPC set FPSCR Intrinsic Definitions. def int_ppc_setrnd : GCCBuiltin<"__builtin_setrnd">, diff --git a/llvm/test/CodeGen/PowerPC/cfence-double.ll b/llvm/test/CodeGen/PowerPC/cfence-double.ll --- a/llvm/test/CodeGen/PowerPC/cfence-double.ll +++ b/llvm/test/CodeGen/PowerPC/cfence-double.ll @@ -1,10 +1,11 @@ +; REQUIRES: asserts ; RUN: not --crash llc -opaque-pointers -mtriple=powerpc64le-unknown-unknown \ ; RUN: < %s 2>&1 | FileCheck %s ; RUN: not --crash llc -opaque-pointers -mtriple=powerpc64-unknown-unknown \ ; RUN: < %s 2>&1 | FileCheck %s -; CHECK: Intrinsic has incorrect argument type! -; CHECK: ptr @llvm.ppc.cfence.f64 +; CHECK: Assertion `VT.isInteger() && Operand.getValueType().isInteger() && "Invalid ANY_EXTEND!"' failed + define double @foo(double* %dp) { entry: %0 = load atomic double, double* %dp acquire, align 8 diff --git a/llvm/test/CodeGen/PowerPC/cfence-float.ll b/llvm/test/CodeGen/PowerPC/cfence-float.ll --- a/llvm/test/CodeGen/PowerPC/cfence-float.ll +++ b/llvm/test/CodeGen/PowerPC/cfence-float.ll @@ -1,10 +1,11 @@ +; REQUIRES: asserts ; RUN: not --crash llc -opaque-pointers -mtriple=powerpc64le-unknown-unknown \ ; RUN: < %s 2>&1 | FileCheck %s ; RUN: not --crash llc -opaque-pointers -mtriple=powerpc64-unknown-unknown \ ; RUN: < %s 2>&1 | FileCheck %s -; CHECK: Intrinsic has incorrect argument type! -; CHECK: ptr @llvm.ppc.cfence.f32 +; CHECK: Assertion `VT.isInteger() && Operand.getValueType().isInteger() && "Invalid ANY_EXTEND!"' failed + define float @bar(float* %fp) { entry: %0 = load atomic float, float* %fp acquire, align 4 diff --git a/llvm/test/CodeGen/PowerPC/issue55983.ll b/llvm/test/CodeGen/PowerPC/issue55983.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/issue55983.ll @@ -0,0 +1,43 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -opaque-pointers -mtriple=powerpc64le-unknown-unknown < %s | FileCheck --check-prefix=CHECK-LE %s +; RUN: llc -opaque-pointers -mtriple=powerpc64-unknown-unknown < %s | FileCheck %s + +define ptr @foo(ptr %p) { +; CHECK-LE-LABEL: foo: +; CHECK-LE: # %bb.0: # %entry +; CHECK-LE-NEXT: ld 3, 0(3) +; CHECK-LE-NEXT: cmpd 7, 3, 3 +; CHECK-LE-NEXT: bne- 7, .+4 +; CHECK-LE-NEXT: isync +; CHECK-LE-NEXT: blr +; +; CHECK-LABEL: foo: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: ld 3, 0(3) +; CHECK-NEXT: cmpd 7, 3, 3 +; CHECK-NEXT: bne- 7, .+4 +; CHECK-NEXT: isync +; CHECK-NEXT: blr +entry: + %0 = load atomic ptr, ptr %p acquire, align 8 + ret ptr %0 +} + +define void @foobar({} addrspace(10)* addrspace(11)* %p) { +; CHECK-LE-LABEL: foobar: +; CHECK-LE: # %bb.0: # %entry +; CHECK-LE-NEXT: ld 3, 0(3) +; CHECK-LE-NEXT: cmpd 7, 3, 3 +; CHECK-LE-NEXT: bne- 7, .+4 +; CHECK-LE-NEXT: isync +; +; CHECK-LABEL: foobar: +; CHECK: # %bb.0: # %entry +; CHECK-NEXT: ld 3, 0(3) +; CHECK-NEXT: cmpd 7, 3, 3 +; CHECK-NEXT: bne- 7, .+4 +; CHECK-NEXT: isync +entry: + %0 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %p acquire, align 8 + unreachable +} diff --git a/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-double.ll b/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-double.ll --- a/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-double.ll +++ b/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-double.ll @@ -1,11 +1,17 @@ -; RUN: not --crash opt -S -atomic-expand -mtriple=powerpc64le-unknown-unknown \ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -atomic-expand -mtriple=powerpc64le-unknown-unknown \ ; RUN: -opaque-pointers < %s 2>&1 | FileCheck %s -; RUN: not --crash opt -S -atomic-expand -mtriple=powerpc64-unknown-unknown \ +; RUN: opt -S -atomic-expand -mtriple=powerpc64-unknown-unknown \ ; RUN: -opaque-pointers < %s 2>&1 | FileCheck %s -; CHECK: Intrinsic has incorrect argument type! -; CHECK: ptr @llvm.ppc.cfence.f64 define double @foo(double* %dp) { +; CHECK-LABEL: @foo( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = load atomic i64, ptr [[DP:%.*]] monotonic, align 8 +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64 [[TMP0]] to double +; CHECK-NEXT: call void @llvm.ppc.cfence.f64(double [[TMP1]]) +; CHECK-NEXT: ret double [[TMP1]] +; entry: %0 = load atomic double, double* %dp acquire, align 8 ret double %0 diff --git a/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-float.ll b/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-float.ll --- a/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-float.ll +++ b/llvm/test/Transforms/AtomicExpand/PowerPC/cfence-float.ll @@ -1,11 +1,17 @@ -; RUN: not --crash opt -S -atomic-expand -mtriple=powerpc64le-unknown-unknown \ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -atomic-expand -mtriple=powerpc64le-unknown-unknown \ ; RUN: -opaque-pointers < %s 2>&1 | FileCheck %s -; RUN: not --crash opt -S -atomic-expand -mtriple=powerpc64-unknown-unknown \ +; RUN: opt -S -atomic-expand -mtriple=powerpc64-unknown-unknown \ ; RUN: -opaque-pointers < %s 2>&1 | FileCheck %s -; CHECK: Intrinsic has incorrect argument type! -; CHECK: ptr @llvm.ppc.cfence.f32 define float @bar(float* %fp) { +; CHECK-LABEL: @bar( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = load atomic i32, ptr [[FP:%.*]] monotonic, align 4 +; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32 [[TMP0]] to float +; CHECK-NEXT: call void @llvm.ppc.cfence.f32(float [[TMP1]]) +; CHECK-NEXT: ret float [[TMP1]] +; entry: %0 = load atomic float, float* %fp acquire, align 4 ret float %0 diff --git a/llvm/test/Transforms/AtomicExpand/PowerPC/issue55983.ll b/llvm/test/Transforms/AtomicExpand/PowerPC/issue55983.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/AtomicExpand/PowerPC/issue55983.ll @@ -0,0 +1,29 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -opaque-pointers -atomic-expand -S -mtriple=powerpc64le-unknown-unknown \ +; RUN: %s | FileCheck %s +; RUN: opt -opaque-pointers -atomic-expand -S -mtriple=powerpc64-unknown-unknown \ +; RUN: %s | FileCheck %s + +define ptr @foo(ptr %p) { +; CHECK-LABEL: @foo( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = load atomic ptr, ptr [[P:%.*]] monotonic, align 8 +; CHECK-NEXT: call void @llvm.ppc.cfence.p0(ptr [[TMP0]]) +; CHECK-NEXT: ret ptr [[TMP0]] +; +entry: + %0 = load atomic ptr, ptr %p acquire, align 8 + ret ptr %0 +} + +define void @foobar({} addrspace(10)* addrspace(11)* %p) { +; CHECK-LABEL: @foobar( +; CHECK-NEXT: entry: +; CHECK-NEXT: [[TMP0:%.*]] = load atomic ptr addrspace(10), ptr addrspace(11) [[P:%.*]] monotonic, align 8 +; CHECK-NEXT: call void @llvm.ppc.cfence.p10(ptr addrspace(10) [[TMP0]]) +; CHECK-NEXT: unreachable +; +entry: + %0 = load atomic {} addrspace(10)*, {} addrspace(10)* addrspace(11)* %p acquire, align 8 + unreachable +}