The sign information for binary operators is available in the llvm IR by the 'nsw' (no signed wrap) flag. Seems there is no use of this flag in the code generation phase. The sign information is no more available in the selection DAG. So how can I generate different instructions for binary operators with signed/unsigned operands in the assembler (e.g. mul/mulu)? -- View this message in context: http://llvm.1065342.n5.nabble.com/Signed-Unsigned-Instruction-selection-tp70286.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On Jul 9, 2014, at 1:08 AM, Arsen Hakobyan <artinetstudio at gmail.com> wrote:> The sign information for binary operators is available in the llvm IR by the > 'nsw' (no signed wrap) flag. Seems there is no use of this flag in the code > generation phase. > The sign information is no more available in the selection DAG. > So how can I generate different instructions for binary operators with > signed/unsigned operands in the assembler (e.g. mul/mulu)?It actually is, although it’s a relatively recent addition. See BinaryWithFlagsSDNode
> The sign information is no more available in the selection DAG. > So how can I generate different instructions for binary operators with > signed/unsigned operands in the assembler (e.g. mul/mulu)?Instructions where it actually matters (assuming 2s-complement representation) have different nodes in the DAG. If you look at include/llvm/CodeGen/ISDOpcodes.h you'll see separate UDIV and SDIV nodes, for example. It only usually affects multiplications if you're doing an extend at the same time (hence the MULHS, SMUL_LOHI and friends) or care about overflow (hence SMULO/UMULO). Cheers. Tim.
Hi Matt, Hi Tim, Thank you very much for your suggestions. Arsen -- View this message in context: http://llvm.1065342.n5.nabble.com/Signed-Unsigned-Instruction-selection-tp70286p70476.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Apparently Analagous Threads
- [LLVMdev] [PATH] Add sub.ovf/mul.ovf intrinsics
- [LLVMdev] Passing specific register for an Instruction in target description files.
- [LLVMdev] Related constant folding of floating point values
- StripDeadDebugInfo for static inline functions.
- StripDeadDebugInfo for static inline functions.