[PATCH] D152538: `G_ATOMICRMW_NAND` failure in legalizer

niwin anto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 10 10:35:22 PDT 2023


niwinanto updated this revision to Diff 530228.
niwinanto marked an inline comment as done.
niwinanto added a comment.

More feedback addressed.


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

https://reviews.llvm.org/D152538

Files:
  llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
  llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp


Index: llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
===================================================================
--- llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
+++ llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
@@ -4174,4 +4174,40 @@
   EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
 }
 
+// ATOMICRMW_NAND widening.
+TEST_F(AArch64GISelMITest, WidenATOMICRMW_NAND) {
+  setUp();
+  if (!TM)
+    return;
+
+  LLT S64 = LLT::scalar(64);
+  // Declare your legalization info
+  DefineLegalizerInfo(A, {
+    getActionDefinitionsBuilder(G_ATOMICRMW_NAND)
+        .legalFor({{s64, LLT::pointer(0, 64)}});
+  });
+
+  auto Val = B.buildConstant(LLT::scalar(32), 1).getReg(0);
+  auto Addr = B.buildConstant(LLT::pointer(0, 64), 1).getReg(0);
+  MachineMemOperand *MMO = MF->getMachineMemOperand(
+      MachinePointerInfo(),
+      MachineMemOperand::MOLoad | MachineMemOperand::MOStore, 8, Align(8),
+      AAMDNodes(), nullptr, SyncScope::System, AtomicOrdering::Unordered);
+
+  auto MIBAtomicRMWNand = B.buildAtomicRMW(llvm::TargetOpcode::G_ATOMICRMW_NAND,
+                                           LLT::scalar(32), Addr, Val, *MMO);
+  AInfo Info(MF->getSubtarget());
+  DummyGISelObserver Observer;
+  LegalizerHelper Helper(*MF, Info, Observer, B);
+  EXPECT_TRUE(Helper.widenScalar(*MIBAtomicRMWNand, 0, S64) ==
+              LegalizerHelper::LegalizeResult::Legalized);
+
+  auto CheckStr = R"(
+  CHECK: [[ATMNAND:%[0-9]+]]:_(s64) = G_ATOMICRMW_NAND %{{[0-9]+}}:_(p0), %{{[0-9]+}}:_ :: (load store unordered (s64))
+  )";
+
+  // Check
+  EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
+}
+
 } // namespace
Index: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -2029,6 +2029,7 @@
   case TargetOpcode::G_ATOMICRMW_ADD:
   case TargetOpcode::G_ATOMICRMW_SUB:
   case TargetOpcode::G_ATOMICRMW_AND:
+  case TargetOpcode::G_ATOMICRMW_NAND:
   case TargetOpcode::G_ATOMICRMW_OR:
   case TargetOpcode::G_ATOMICRMW_XOR:
   case TargetOpcode::G_ATOMICRMW_MIN:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152538.530228.patch
Type: text/x-patch
Size: 2206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230610/658d1a07/attachment.bin>


More information about the llvm-commits mailing list