[LLVMdev] Removing nuw and nsw

raffael.bild at uni-ulm.de raffael.bild at uni-ulm.de
Mon Nov 26 08:14:03 PST 2012


Hello everybody,

currently I'm writing a thesis about compiler optimization techniques  
and I've choosen LLVM as a framework for implementing and testing my  
ideas.

While reading the LLVM Language Reference Manual I noticed that the  
nuw and nsw keywords for the instructions add, sub and mul complicate  
reasoning about integer arithmetic for the purpose of my thesis  
somewhat. Things would be easier for me if there would be just the  
plain variants of these instructions so I could formally treat them  
modular arithmetic operations. Thus, I'm wondering if it's a valid  
transformation to simply drop these keywords during an optimisation  
pass ...

As I see it, the effect of nuw resp. nsw is to create poison values in  
case of an overflow, which are essentially undefined values with the  
additional effect that they can cause other operation that depend on  
them to also produce poison values. So, as I understand it, removing  
these keywords would basically turn undefined values into defined  
ones, thus dropping some information that could be used for further  
optimizations, but it would not strictly speaking be an incorrect  
transformation - is this correct or do I miss or misunderstand  
something?

Thanks in advance for any comments and insights about this matter!

Raffael Bild




More information about the llvm-dev mailing list