[all-commits] [llvm/llvm-project] c31eb8: [BasicAA] Fix nsw handling for negated scales (PR6...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Tue Jun 27 00:40:26 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: c31eb827b72da784d7f18512a51e5396ac302d72
https://github.com/llvm/llvm-project/commit/c31eb827b72da784d7f18512a51e5396ac302d72
Author: Nikita Popov <npopov at redhat.com>
Date: 2023-06-27 (Tue, 27 Jun 2023)
Changed paths:
M llvm/lib/Analysis/BasicAliasAnalysis.cpp
M llvm/test/Analysis/BasicAA/range.ll
Log Message:
-----------
[BasicAA] Fix nsw handling for negated scales (PR63266)
We currently preserve the nsw flag when negating scales, which is
incorrect for INT_MIN.
However, just dropping the NSW flag in this case makes BasicAA
behavior unreliable and asymmetric, because we may or may not
drop the NSW flag depending on which side gets subtracted.
Instead, leave the Scale alone and add an additional IsNegated flag,
which indicates that the whole VarIndex should be interpreted as a
subtraction. This allows us to retain the NSW flag.
When accumulating the offset range, we need to use subtraction
instead of adding for IsNegated indices. Everything else works on
the absolute value of the scale, so the negation does not matter
there.
Fixes https://github.com/llvm/llvm-project/issues/63266.
Differential Revision: https://reviews.llvm.org/D153270
More information about the All-commits
mailing list