[llvm] r354171 - [InstCombine] Address a couple stylistic issues pointed out by reviewer [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 15 13:31:40 PST 2019


Author: reames
Date: Fri Feb 15 13:31:39 2019
New Revision: 354171

URL: http://llvm.org/viewvc/llvm-project?rev=354171&view=rev
Log:
[InstCombine] Address a couple stylistic issues pointed out by reviewer [NFC]

Better addressing comments from https://reviews.llvm.org/D58290.


Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp?rev=354171&r1=354170&r2=354171&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp Fri Feb 15 13:31:39 2019
@@ -26,8 +26,7 @@ bool isIdempotentRMW(AtomicRMWInst& RMWI
     // TODO: Handle fadd, fsub?
     return false;
 
-  AtomicRMWInst::BinOp Op = RMWI.getOperation();
-  switch(Op) {
+  switch(RMWI.getOperation()) {
     case AtomicRMWInst::Add:
     case AtomicRMWInst::Sub:
     case AtomicRMWInst::Or:
@@ -55,12 +54,12 @@ bool isSaturating(AtomicRMWInst& RMWI) {
   if(!C)
     return false;
 
-  AtomicRMWInst::BinOp Op = RMWI.getOperation();
-  switch(Op) {
+  switch(RMWI.getOperation()) {
   default:
     // TODO: fadd, fsub w/Nan
-    // Note: We avoid listing xchg to prevent transform cycles.
     return false;
+  case AtomicRMWInst::Xchg:
+    return true;
   case AtomicRMWInst::Or:
     return C->isAllOnesValue();
   case AtomicRMWInst::And:
@@ -87,7 +86,8 @@ Instruction *InstCombiner::visitAtomicRM
 
   // Any atomicrmw op which produces a known result in memory can be
   // replaced w/an atomicrmw xchg.
-  if (isSaturating(RMWI)) {
+  if (isSaturating(RMWI) &&
+      RMWI.getOperation() != AtomicRMWInst::Xchg) {
     RMWI.setOperation(AtomicRMWInst::Xchg);
     return &RMWI;
   }




More information about the llvm-commits mailing list