[PATCH] D142166: [X86] In `shouldExpandLogicAtomicRMWInIR` return `CmpXChg` instead of asserting if we don't match op(0)

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 16:53:02 PST 2023


goldstein.w.n created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
goldstein.w.n requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The old code from `D140939` asserted that the AtomicRMW was operand(0)
which isn't necessarily the case.

It was previously relatively safe to assume this, as we only matched
constants (which cannonicalize to op(1) being constant), but now we
can match non-constant power of 2 which don't have that
canonicalization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142166

Files:
  llvm/lib/Target/X86/X86ISelLowering.cpp


Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -31529,7 +31529,9 @@
       AI->getParent() != I->getParent())
     return AtomicExpansionKind::CmpXChg;
 
-  assert(I->getOperand(0) == AI);
+  if (I->getOperand(0) != AI)
+    return AtomicExpansionKind::CmpXChg;
+
   // The following instruction must be a AND single bit.
   if (BitChange.second == ConstantBit || BitChange.second == NotConstantBit) {
     auto *C1 = dyn_cast<ConstantInt>(AI->getValOperand());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142166.490688.patch
Type: text/x-patch
Size: 621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230120/8945ba54/attachment.bin>


More information about the llvm-commits mailing list