1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Transforms: lower fadd and fsub atomicrmw instructions

`fadd` and `fsub` have recently (r351850) been added as `atomicrmw`
operations. This diff adds lowering cases for them to the LowerAtomic
transform.

Patch by Josh Berdine!

llvm-svn: 361512
This commit is contained in:
Saleem Abdulrasool 2019-05-23 17:03:43 +00:00
parent d18dde10f1
commit 0d19bba33e
2 changed files with 28 additions and 0 deletions

View File

@ -86,6 +86,12 @@ static bool LowerAtomicRMWInst(AtomicRMWInst *RMWI) {
Res = Builder.CreateSelect(Builder.CreateICmpULT(Orig, Val),
Orig, Val);
break;
case AtomicRMWInst::FAdd:
Res = Builder.CreateFAdd(Orig, Val);
break;
case AtomicRMWInst::FSub:
Res = Builder.CreateFSub(Orig, Val);
break;
}
Builder.CreateStore(Res, Ptr);
RMWI->replaceAllUsesWith(Orig);

View File

@ -35,3 +35,25 @@ define i8 @min() {
ret i8 %j
; CHECK: ret i8 [[INST]]
}
define float @fadd() {
; CHECK-LABEL: @fadd(
%i = alloca float
%j = atomicrmw fadd float* %i, float 42.0 monotonic
; CHECK: [[INST:%[a-z0-9]+]] = load
; CHECK-NEXT: fadd
; CHECK-NEXT: store
ret float %j
; CHECK: ret float [[INST]]
}
define float @fsub() {
; CHECK-LABEL: @fsub(
%i = alloca float
%j = atomicrmw fsub float* %i, float 42.0 monotonic
; CHECK: [[INST:%[a-z0-9]+]] = load
; CHECK-NEXT: fsub
; CHECK-NEXT: store
ret float %j
; CHECK: ret float [[INST]]
}