<div dir="ltr">You could set IntWidth to 16 or 8 in clang, not unlike what MSP430 does:<div><a href="https://github.com/llvm-mirror/clang/blob/3317d0fa0bd1f5c5adc14bcc6adc2a38acc9064b/lib/Basic/Targets.cpp#L6823">https://github.com/llvm-mirror/clang/blob/3317d0fa0bd1f5c5adc14bcc6adc2a38acc9064b/lib/Basic/Targets.cpp#L6823</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 27, 2016 at 10:32 AM, Dilan Manatunga via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-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">I need disabling this feature because I am researching architectures where 8-bit or 16-bit adds are preferred to 32-bit. So, integer promotion kinda mucks everything up. I was hoping there was a way in clang to disable it, instead of having to implement an LLVM pass to coalesce unnecessary promotions. <br><div><br></div><div>Thanks for catching the IR mistake. Should have double checked that. This should be the correct version:</div><div><span class=""><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">nt8_t a = 1;</div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">int8_t b = 2;</div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">int8_t c = a + b</div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal"><br></div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">The LLVM IR will be:</div></span><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">%x = sext i8 %a to i32</div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">%y = sext i8 %b to i32</div><span class=""><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">%z = add nsw i32 %x, %y</div></span><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">%c = trunc i32 %z to i8</div><span class=""><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal"><br></div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">Instead, it would simply compile to:</div></span><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">$c = add nsw i8 %z, $y</div></div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal"><br></div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal">-Dilan</div><div style="font-family:verdana,geneva,helvetica,arial,sans-serif;font-size:13.44px;line-height:normal"><br></div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Fri, May 27, 2016 at 5:30 AM Norman Rink via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dilan,<br>
<br>
I would like to second your request for an option to disable integer<br>
promotion. What do you need it for?<br>
<br>
As far as I am aware, there is no such option and the code that implements<br>
integer promotion is somewhat scattered across ³SemaExpr.cpp².<br>
<br>
Also, I think your example code snippet contains a few ³i32²s too many. It<br>
will be clearer to people what you are looking for if your code example is<br>
consistent with your question.<br>
<br>
Best,<br>
<br>
Norman<br>
<br>
<br>
>Message: 1<br>
>Date: Fri, 27 May 2016 01:50:12 +0000<br>
>From: Dilan Manatunga via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
>To: <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
>Subject: [cfe-dev] Disable integer promotion<br>
>Message-ID:<br>
> <CAHpgGu4=<a href="mailto:jFC9ohQQZZMp2NMG3Hw0sE5U4-Lqrgb%2B6gcXv9SEtQ@mail.gmail.com" target="_blank">jFC9ohQQZZMp2NMG3Hw0sE5U4-Lqrgb+6gcXv9SEtQ@mail.gmail.com</a>><br>
>Content-Type: text/plain; charset="utf-8"<br>
><br>
>Is there a way to disable integer promotion when performing math<br>
>operations. For example, when compiling a statement such as this:<br>
>int8_t a = 1;<br>
>int8_t b = 2;<br>
>int8_t c = a + b<br>
><br>
>The LLVM IR will be:<br>
>%x = sext i32 %a to i32<br>
>%y = sext i32 %b to i32<br>
>%z = add nsw i32 %x, %y<br>
>%c = trunc i32 %z to i16<br>
><br>
>Instead, it would simply compile to:<br>
>$c = add nsw i32 %z, $y<br>
><br>
>-Dilan Manatunga<br>
>-------------- next part --------------<br>
>An HTML attachment was scrubbed...<br>
>URL:<br>
><<a href="http://lists.llvm.org/pipermail/cfe-dev/attachments/20160527/4a7920ab/att" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/cfe-dev/attachments/20160527/4a7920ab/att</a><br>
>achment-0001.html><br>
><br>
>------------------------------<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>