Closed zhping8080 closed 1 year ago
You can use __builtin_add_overflow. See https://godbolt.org/z/6qsPqaWz3 for example.
llvm.sadd.with.overflow is converted to ISD::SADDO in SelectionDAG. How it is handled after that is target specific.
Thank you very much!
I find that when two i16 numbers or i8 numbers are added, it will be extended to i32. Even if I choose to compile it with '-fsanitize=undefined'. So, How can generate the intrinsic 'call @llvm.sadd.with.overflow.i16' ? Additional, how can I find the implementation of llvm.sadd.with.overflow.* in LLVM source code? It's a bit challenging for newbies. Thanks!