[llvm] r361512 - Transforms: lower fadd and fsub atomicrmw instructions
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 10:03:44 PDT 2019
Author: compnerd
Date: Thu May 23 10:03:43 2019
New Revision: 361512
URL: http://llvm.org/viewvc/llvm-project?rev=361512&view=rev
Log:
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!
Modified:
llvm/trunk/lib/Transforms/Scalar/LowerAtomic.cpp
llvm/trunk/test/Transforms/LowerAtomic/atomic-load.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LowerAtomic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LowerAtomic.cpp?rev=361512&r1=361511&r2=361512&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LowerAtomic.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LowerAtomic.cpp Thu May 23 10:03:43 2019
@@ -86,6 +86,12 @@ static bool LowerAtomicRMWInst(AtomicRMW
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);
Modified: llvm/trunk/test/Transforms/LowerAtomic/atomic-load.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerAtomic/atomic-load.ll?rev=361512&r1=361511&r2=361512&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LowerAtomic/atomic-load.ll (original)
+++ llvm/trunk/test/Transforms/LowerAtomic/atomic-load.ll Thu May 23 10:03:43 2019
@@ -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]]
+}
More information about the llvm-commits
mailing list