[InstCombine] Restrict "C-(X+C2) --> (C-C2)-X" fold to immediate constants
authorRoman Lebedev <lebedev.ri@gmail.com>
Wed, 7 Apr 2021 08:50:14 +0000 (11:50 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Wed, 7 Apr 2021 09:06:24 +0000 (12:06 +0300)
commit93d1d94b745b940c9ad0adf20322eb16ed624ef3
treeb19b8f5a8682142f5811d7bb281daf26ee0f7e82
parentc972e2d1c29fc248e47f1c502f90472a1c26b256
[InstCombine] Restrict "C-(X+C2) --> (C-C2)-X" fold to immediate constants

I.e., if any/all of the consants is an expression, don't do it.
Since those constants won't reduce into an immediate,
but would be left as an constant expression, they could cause
endless combine loops after 31d219d2997fed1b7dc97e0adf170d5aaf65883e
added an inverse transformation.
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub-from-sub.ll