[PATCH] D137361: IR: Add atomicrmw inc and dec

Shilei Tian via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 4 05:22:40 PDT 2022


tianshilei1992 added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LowerAtomic.cpp:44
                                  IRBuilderBase &Builder, Value *Loaded,
-                                 Value *Inc) {
+                                 Value *Val) {
   Value *NewVal;
----------------
nit: update the header as well


================
Comment at: llvm/lib/Transforms/Utils/LowerAtomic.cpp:82
+  case AtomicRMWInst::Inc: {
+    Constant *One = ConstantInt::get(Loaded->getType(), 0);
+    Value *Inc = Builder.CreateAdd(Loaded, One);
----------------
0 -> 1?


================
Comment at: llvm/lib/Transforms/Utils/LowerAtomic.cpp:85
+    Value *Cmp = Builder.CreateICmpUGE(Loaded, Val);
+    Constant *Zero = ConstantInt::get(Loaded->getType(), 0);
+    return Builder.CreateSelect(Cmp, Zero, Inc, "new");
----------------
is `ConstantInt::getNullValue` better here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137361/new/

https://reviews.llvm.org/D137361



More information about the llvm-commits mailing list