[LLVMdev] ICmp documentation clarification

Reid Spencer rspencer at reidspencer.com
Fri Jan 5 01:23:12 PST 2007


Hi Baptiste,

On Fri, 2007-01-05 at 09:44 +0100, Baptiste Lepilleur wrote:
> I just want to make sure I understand the semantic of the icmp function 
> correctly as assumption are dangerous in this domain.
> 
> The syntax is specified as follow:
> <result> = icmp <cond> <ty> <var1>, <var2>   ; yields {bool}:result
> 
> But I can not find the documentation for <ty>. 

<ty> is any of the integer types or a pointer type. It cannot be any
other type. The type of var1 and var2 must be identical and must be <ty>

> Is the following 
> interpretation correct:
> Both <var1> and <var2> are converted to <ty> using the semantic of the trunc 
> instruction before processing the comparison operation.

No, <var1> and <var2> are not converted or modified by this instruction.
The values of the integers or pointers are compared, that's it.

> Concerning instruction trunc, is bool considered to be an alias to type i1. 

Yes.

> If so, does the following stand true:
> %Y = trunc i32 123 to bool               ; yields bool:true

Yes. When you truncate to bool, it really truncates so only the least
significant bit is retained.

> %Y = trunc i32 122 to bool               ; yields bool:falseBaptiste. 

Yes.

> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list