Hi,
Which of the following way is suggested?
(1) Use arith::ExtSIOp
to extend Int1 Value
to Int32 Value
(2) Use arith::SelectOp
like: select(i1_pred, i32_1, i32_0)
Or is there any other approach?
Thanks in advance!
Hi,
Which of the following way is suggested?
(1) Use arith::ExtSIOp
to extend Int1 Value
to Int32 Value
(2) Use arith::SelectOp
like: select(i1_pred, i32_1, i32_0)
Or is there any other approach?
Thanks in advance!
The two canonical approaches are using either arith.extsi
or araith.extui
. They differ in how they interpret the sign of the i1
. The former interprets it as a signed number, meaning a 0b1
bit pattern is seen as -1
and is then also extended to a i32
with the value -1
as well.
extui
interprets it as an unsigned number instead and would extend it to a i32
with the value 1
.
Which one you need depends on what you want. I think the extui
of i1
is a bit more common.
Thanks for your reply!