JIT: Arm `IsContainableImmed` doesnt handle shifts
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
```cpp
GenTree* shiftConst = m_compiler->gtNewIconNode(31, TYP_INT);
GenTree* sar = m_compiler->gtNewOperNode(GT_RSH, select->TypeGet(), relopOp1, shiftConst);
CheckImmedAndMakeContained(sar, shiftConst); // false
```
`CheckImmedAndMakeContained` calls into [`IsContainableImmed`](https://github.com/dotnet/runtime/blob/388a7c4814cb0d6e344621d017507b357902043a/src/coreclr/jit/lowerarmarch.cpp#L94) which on arm doesn't handle shifts and returns false so that `shiftConst` doesn't get contained even though it could.
The weird thing is that the higher level function `ContainCheckNode` handles it. That's because it doesn't actually call into `CheckImmedAndMakeContained`. Meanwhile for other nodes like add the higher level function **does** call into lower level `CheckImmedAndMakeContained`:
Add:
ContainCheckNode -> ContainCheckBinary -> CheckImmedAndMakeContained -> IsContainableImmed -> MakeSrcContained
Rsh:
ContainCheckNode -> ContainCheckShiftRotate -> shiftBy->IsCnsIntOrI -> MakeSrcContained
Maybe `ContainCheckShiftRotate` should call `CheckImmedAndMakeContained` which should handle shifts?
Contributor guide
Assessment
This issue has not been assessed yet.