From ba66e8fd7639d677bd4d10ef10415a2969f08908 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 15 Feb 2019 21:31:39 +0000 Subject: [PATCH] [InstCombine] Address a couple stylistic issues pointed out by reviewer [NFC] Better addressing comments from https://reviews.llvm.org/D58290. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354171 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp b/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp index 58da7eb6759..b857741e840 100644 --- a/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp +++ b/lib/Transforms/InstCombine/InstCombineAtomicRMW.cpp @@ -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::visitAtomicRMWInst(AtomicRMWInst &RMWI) { // 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; } -- 2.50.1