[llvm-dev] trunc nsw/nuw?

Alexandre Isoard via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 3 12:38:45 PDT 2017


Hello,

>From [1], trunc does not seems to have a nsw/nuw attribute.
Is it possible to have that? Or do we have that and it is not up-to-date?

The definition would be:

If the nuw keyword is present, the result value of the trunc is a poison
value if the truncated high order bits are non-zero. If the nsw keyword is
present, the result value of the trunc is a poison value if the truncated
high order bits are not all equal to the non-truncated bit of the highest
order.

This allow to cancel out:
- sext with trunc nsw
- zext with trunc nuw

And probably to commute with add/sub/mul/lshr/ashr/shl/urem/udiv/udiv (with
the correct flags).

[1]: http://llvm.org/docs/LangRef.html#trunc-to-instruction

-- 
*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170703/5fb31f9a/attachment.html>


More information about the llvm-dev mailing list