[llvm-dev] unsigned operations with negative numbers
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 31 06:59:37 PDT 2017
On 31 July 2017 at 01:56, Anastasiya Ruzhanskaya via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> What should I expect from sign of the operand if I get the line:
> %1 = udiv i32 %a.o, 2. Can it in this case be negative.
LLVM integers don't really have a sign and are just bags of bits. It's
the operations that interpret those as signed or unsigned integers and
udiv's arguments are unsigned.
They're printed as signed numbers purely for convenience (-2 is a lot
more recognisable than 4294967294)
> Or this situation is
> only the result of under optimization and zero value is ok?
I'm not sure what you mean by zero here. The result of your first
division example will be 0.
More information about the llvm-dev