[LLVMdev] arithmetical operands signedness
Duncan Sands
baldrick at free.fr
Mon Sep 5 08:48:05 PDT 2011
Hi Jonas,
> my target handles operands of multiplying instructions differently based on
> signedness.
since the result of a multiply doesn't depend on the signedness, I find it
strange that your target differentiates between them. What I'm saying is
that if you have (say) two i32 numbers a and b and you do a signed multiply:
c = a *s b
and an unsigned multiply
d = a *u b
then c and d are the same number (exactly the same bits set).
>
> I wonder then how I would do instruction selection based on the operands signs?
>
> The mul instruction sets a nsw for signed,
No it doesn't. nsw doesn't mean signed, it means that if the multiplication
would overflow as a signed multiplication then the result is undefined which
is completely different.
but when i try unsigned ops, there is
> no wrap flag at all. I'm not sure this is enough information to work with, or?
No information is needed, see above.
Ciao, Duncan.
More information about the llvm-dev
mailing list