[llvm-dev] Meaning of `sub nsw`

Peng Yu via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 1 04:35:29 PST 2019


In the following code.
	unsigned char x1 = atoi(argv[1]);
	unsigned char x2 = atoi(argv[2]);
	printf("%d\n", x1-x2);

The substraction of the last command is translated to the following IR code.

%18 = load i8, i8* %6, align 1
%19 = zext i8 %18 to i32
%20 = load i8, i8* %7, align 1
%21 = zext i8 %20 to i32
%22 = sub nsw i32 %19, %21

I don't follow the explanation of nsw in langref. Could anybody help
explain what nsw means here? Thanks.


-- 
Regards,
Peng


More information about the llvm-dev mailing list