Closed Leonardo2718 closed 5 years ago
Like #3525, this issue was discovered in #3499 by changing the Tril backend from JitBuilder to the Test Compiler. The former runs GRA while the latter does not. Running GRA hides this issue by causing arguments to be loaded directly from the argument registers without spilling and reloading.
When GRA is disabled, code generators are required to spill arguments that come in registers and to reload them when an argument value is used.
Given the following trees:
the Power code generator generates the following code (GRA is disabled; 64-bit LE Power Linux machine):
At line 7, the first argument is loaded as a byte into r0 and is zero-extended. At line 9,
sraw
does a word (32-bit) arithmetic right-shift of the value in r0. However, the value must first be sign-extended in order for the shift to correctly apply to the byte value.Also, given the following trees:
the Power code generator generates:
In this case, the first argument, a half-word, is loaded at line 7 and sign-extended. However, for the logical shift-right at line 9 to correctly apply to the 16-bit value, it must be zero-extended instead.
Finally, there is another issue, related to #3525, where sub-integer sized arguments are spilled to the stack as 32-bit words but are reloaded with a different bit width. The issue is not causing immediate problems because tests are only run on LE systems where narrowing conversions can be done without changing the base address of a value in memory.