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>. 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. Concerning instruction trunc, is bool considered to be an alias to type i1. If so, does the following stand true: %Y = trunc i32 123 to bool ; yields bool:true%Y = trunc i32 122 to bool ; yields bool:falseBaptiste.
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:trueYes. 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
Reid Spencer wrote:> 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>Thanks this clear things up. What is the rational behind the existance of both icmp and fcmp as the i/f prefix seems to be redundant with <ty> ? Is it for performance purpose when analysing the code ?>> [...] > 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:falseMaybe this example should be added to the doc to clarify this point. Thanks, Baptiste.