I would like to second your request for an option to disable integer
promotion. What do you need it for?
As far as I am aware, there is no such option and the code that implements
integer promotion is somewhat scattered across ³SemaExpr.cpp².
Also, I think your example code snippet contains a few ³i32²s too many. It
will be clearer to people what you are looking for if your code example is
consistent with your question.
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.
Thanks for catching the IR mistake. Should have double checked that. This should be the correct version:
nt8_t a = 1;
int8_t b = 2;
int8_t c = a + b
The LLVM IR will be:
%x = sext i8 %a to i32
%y = sext i8 %b to i32
%z = add nsw i32 %x, %y
%c = trunc i32 %z to i8
Instead, it would simply compile to:
$c = add nsw i8 %z, $y