[PATCH] D152538: `G_ATOMICRMW_NAND` failure in legalizer
niwin anto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 9 12:14:21 PDT 2023
niwinanto updated this revision to Diff 530049.
niwinanto added a comment.
Added testcase.
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,41 @@
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 OldValRes = MRI->createGenericVirtualRegister(LLT::scalar(32));
+ auto Addr = MRI->createGenericVirtualRegister(LLT::pointer(0, 64));
+ auto Val = MRI->createGenericVirtualRegister(LLT::scalar(32));
+ MachineMemOperand *MMO = MF->getMachineMemOperand(
+ MachinePointerInfo(),
+ MachineMemOperand::MOLoad | MachineMemOperand::MOStore, 8, Align(8),
+ AAMDNodes(), nullptr, SyncScope::System, AtomicOrdering::Unordered);
+
+ auto MIBAtomicRMWNand = B.buildAtomicRMWNand(OldValRes, 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
+ )";
+
+ // 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.530049.patch
Type: text/x-patch
Size: 2142 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230609/66d05222/attachment.bin>
More information about the llvm-commits
mailing list