<div dir="ltr">LLVM IR integers have no sign. You can't reliably tell whether an add or subtract was signed or unsigned when generating code.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 15, 2017 at 10:19 AM, Ryan Taylor via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I'm curious why 'unsigned short w = 0x8000' is displayed as -32768 in the IR?</div><div> </div><div>This propagates to the DAG and hence tablegen, where I am missing matching on some immediates because the immediate is not being looked at as unsigned? For example, we have no issue if instead of 0x8000 we use 0x7FFF, then everything is fine, the match is fine.</div><div><br></div><div>I can understand that it's just being printed as 'signed' even when it's unsigned due to the bit pattern (2s complement)  but it seems to affect matching.</div><div><br></div><div>We'd like;</div><div><br></div><div>unsigned short x, y;</div><div>int main() {</div><div>   unsigned short w = 0x8000;</div><div>   y = w - x;</div><div>   return 0;</div><div>}</div><div><br></div><div>To match to something like 'sub16u $0x8000, x, y' (if I set w = 0x7FFF, then we get sub16u $0x7FFF, x, y' but not when using 0x8000).</div><div><br></div><div>We have some code to determine if the operation is a signed or unsigned operation in tablegen. Can anyone suggest a good way to get around this? </div><div><br></div><div>Thanks,</div><div>Ryan</div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>