[llvm-dev] trunc nsw/nuw?
Nuno Lopes via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 3 14:11:37 PDT 2017
LLVM currently doesn't have trunc nsw/nuw, no.
Which frontend would emit such instructions? Any application in mind?
Just asking because if no frontend could emit those, then the motivation to
add nsw/nuw support to trunc would be very low I guess.
From: Alexandre Isoard via llvm-dev
Sent: Monday, July 3, 2017 8:38 PM
Subject: [llvm-dev] trunc nsw/nuw?
>From , 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
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).
More information about the llvm-dev