Legalizer fails to widen output type for G_ATOMICRMW_NAND.
Details
Diff Detail
Event Timeline
I am not sure how to trigger this error. I don't see any targets legalizing G_ATOMICRMW_NAND. Only AMD GPU has G_ATOMICRMW_NAND in legalizerInfo, but it is lowered. In our use case we are legalizing it and facing this issue.
You didn't post any patch context so I'm not sure what you're specifically handling here. You just need a mir test with G_ATOMICRMW_NAND and/or an IR test with atomicrmw nand with the appropriate type
Apologies, I could not explain correctly.
For example
%0 = atomicrmw nand ptr @sc, i8 1 seq_cst, align 1
to
%0:_(s8) = G_ATOMICRMW_NAND %1(p0), %2 :: (load store seq_cst (s8) on @s c)
In our use case, s8 for G_ATOMICRMW_NAND is not supported. Hence, trying to widen it to s32.
However, LegalizerHelper::widenScalar(...) does not handle G_ATOMICRMW_NAND, but other G_ATOMICRMW*.
Why I cannot add test/ trigger this error, no other target legalize G_ATOMICRMW_NAND, hence I cannot invoke LegalizerHelper::widenScalar(...).
I think ppc or mips would use this, plus there's always unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp
I was not aware of unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp let me have a look at this.
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | ||
---|---|---|
4197 | MachineMemOperand is not a value. I'm talking about Addr and Val, which are undefined registers here | |
4198 | auto Nand = B.buildAtomicRMW(LLT::scalar(32)) | |
4207 | Also check the inputs | |
4211 | You didn't define the input registers for the instruction |
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | ||
---|---|---|
4198 | I don't get the issue with buildAtomicRMWNand |
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | ||
---|---|---|
4198 | You do not need to pre-create the register. You can pass the type like you did with buildConstant above |
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | ||
---|---|---|
4198 | Thanks for explaining. Now I got it. |
llvm/unittests/CodeGen/GlobalISel/LegalizerHelperTest.cpp | ||
---|---|---|
4197 | Oh, looks like all of these wrappers around specific atomicrmws were never updated |
@arsenm thank you for reviewing this. I do not have the commit access, could you please commit for me.
Niwin Anto <niwin.anto@hightec-rt.com>
Ideally would have some defs for it