aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorAndrzej WarzyƄski <andrzej.warzynski@arm.com>2024-05-08 21:06:03 +0100
committerGitHub <noreply@github.com>2024-05-08 21:06:03 +0100
commitb1da82ae3dba0982b3a9668ca895ddf4164fb3d1 (patch)
tree7831f5ed7bd7404daf8c0ae12c48b0cad95b8eff /llvm/lib/Transforms/Utils/InlineFunction.cpp
parent559accf365a6eb885c24cf15e14aea2eb8e66596 (diff)
downloadllvm-b1da82ae3dba0982b3a9668ca895ddf4164fb3d1.zip
llvm-b1da82ae3dba0982b3a9668ca895ddf4164fb3d1.tar.gz
llvm-b1da82ae3dba0982b3a9668ca895ddf4164fb3d1.tar.bz2
[mlir][arith] Fix overflow bug in arith::CeilDivSIOp::fold (#90947)
The folder for arith::CeilDivSIOp should only be applied when it can be guaranteed that no overflow would happen. The current implementation works fine when both dividends are positive and the only arithmetic operation is the division itself. However, in cases where either the dividend or divisor is negative (or both), the division is split into multiple arith operations, e.g.: `- ( -a / b)`. That's additional 2 operations on top of the actual division that can overflow - the folder should check all 3 ops for overflow. The current logic doesn't do that - it effectively only checks the last operation (i.e. the division). It breaks when using e.g. MININT values (e.g. -128 for 8-bit integers) - negating such values overflows. This PR makes sure that no folding happens if any of the intermediate arithmetic operations overflows. Fixes https://github.com/llvm/llvm-project/issues/89382
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
0 files changed, 0 insertions, 0 deletions