Open bcardosolopes opened 1 month ago
I can repro this for just scalar arith, too. See this program. I guess we are missing the corresponding logic in ScalarExprEmitter. The lowering is correct however.
I checked and it seems Subop has already done this logic, so if no one else has done it, it can be assigned to me https://github.com/llvm/clangir/blob/9720c614b93406c6a08a04887958c2e0e3ad1632/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp#L1317-L1338
If we look at how LLVM currently codegen for this, we get a
add nsw
instead of a plainadd
, see https://godbolt.org/z/xdevh38r8. There are probably other differences too._Originally posted by @bcardosolopes in https://github.com/llvm/clangir/pull/613#discussion_r1630329735_