[PATCH] D58242: Teach instcombine about remaining idemptotent atomicrmw types

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 14 10:02:48 PST 2019


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp:53
+Instruction *InstCombiner::visitAtomicRMWInst(AtomicRMWInst &RMWI) {
+  if (!isIdempotentRMW(RMWI))
+    return nullptr;
----------------
qcolombet wrote:
> IIRC to be pedantic idempotent is when something doesn't change when multiplied by itself, hence this name could be misleading (though I could remember wrong :P).
Idempotent is (copied from Instruction.h):
  ///   Idempotent operators satisfy:  x op x === x
  ///
  /// In LLVM, the And and Or operators are idempotent.

We have similar logic/switch for binop instructions. See:
ConstantExpr::getBinOpIdentity()
(not sure if there's a way to share code between this and that)


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

https://reviews.llvm.org/D58242





More information about the llvm-commits mailing list