[LLVMdev] LangRef description of 'add nsw' doesn't match reality

Paul Melis llvm at assumetheposition.nl
Wed Sep 2 07:31:19 PDT 2009


The langref says for the 'add' instruction:

Syntax:

  <result> = add <ty> <op1>, <op2>          ; yields {ty}:result
  <result> = nuw add <ty> <op1>, <op2>      ; yields {ty}:result
  <result> = nsw add <ty> <op1>, <op2>      ; yields {ty}:result
  <result> = nuw nsw add <ty> <op1>, <op2>  ; yields {ty}:result

But llvm-as does not accept that sequence, only ... = add nsw ... (which
is also what llvm-gcc generates). E.g.

16:29|melis at juggle2:~> cat add.ll | grep nsw
  %2 = nsw add i32 %1, 1                          ; <i32> [#uses=1]
16:29|melis at juggle2:~> llvm-as add.ll
llvm-as: add.ll:14:8: error: expected instruction opcode
  %2 = nsw add i32 %1, 1                          ; <i32> [#uses=1]
       ^
16:29|melis at juggle2:~> cat add2.ll | grep nsw
  %2 = add nsw i32 %1, 1                          ; <i32> [#uses=1]
16:29|melis at juggle2:~> llvm-as add2.ll
16:29|melis at juggle2:~>

It seems the other variants of add (and sub) described also should list
the opcode first, followed by the wrap flag.

Paul




More information about the llvm-dev mailing list