
 llvm/test/Analysis/CallGraph/donothingintrinsic.ll (diff) 

 llvm/test/Transforms/CorrelatedValuePropagation/srem.ll (diff) 
Commit
4eeeb356fc41babf46797b062f74f978b818622b
by lebedev.ri[CVP] Enhance SRem > URem fold to work not just on nonnegative operands
This is a continuation of 8d487668d09fb0e4e54f36207f07c1480ffabbfd, the logic is pretty much identical for SRem:
Name: pos pos Pre: C0 >= 0 && C1 >= 0 %r = srem i8 C0, C1 => %r = urem i8 C0, C1
Name: pos neg Pre: C0 >= 0 && C1 <= 0 %r = srem i8 C0, C1 => %r = urem i8 C0, C1
Name: neg pos Pre: C0 <= 0 && C1 >= 0 %r = srem i8 C0, C1 => %t0 = urem i8 C0, C1 %r = sub i8 0, %t0
Name: neg neg Pre: C0 <= 0 && C1 <= 0 %r = srem i8 C0, C1 => %t0 = urem i8 C0, C1 %r = sub i8 0, %t0
https://rise4fun.com/Alive/Vd6
Now, this new logic does not result in any new catches as of vanilla llvm testsuite + RawSpeed. but it should be virtually compiletime free, and it may be important to be consistent in their handling, because if we had a pair of sdivsrem, and only converted one of them, divrempairs will no longer see them as a pair, and thus not "merge" them.

 llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (diff) 
 llvm/test/Transforms/CorrelatedValuePropagation/srem.ll (diff) 
Commit
b38d897e802664034c7e6e4654328256ed370a61
by lebedev.ri[ConstantRange] binaryXor(): specialcase binary complement case  the result is precise
Use the fact that `~X` is equivalent to `1  X`, which gives us fullyprecise answer, and we only need to specialhandle the wrapped case.
This fires ~16k times for vanilla llvm testsuite + RawSpeed.

 llvm/lib/IR/ConstantRange.cpp (diff) 
 llvm/unittests/IR/ConstantRangeTest.cpp (diff) 
 llvm/include/llvm/IR/ConstantRange.h (diff) 
Commit
2ed9c4c70bbb36fa12d48a73abc2d89c0af80060
by lebedev.ri[ConstantRange] Introduce getActiveBits() method
Much like APInt::getActiveBits(), computes how many bits are needed to be able to represent every value in this constant range, treating the values as unsigned.

 llvm/unittests/IR/ConstantRangeTest.cpp (diff) 
 llvm/lib/IR/ConstantRange.cpp (diff) 
 llvm/include/llvm/IR/ConstantRange.h (diff) 
Commit
ba5afe5588ded61052c8727dbcb0407b5de4410c
by lebedev.ri[NFC][CVP] processUDivOrURem(): refactor to use ConstantRange::getActiveBits()
As an exhaustive test shows, this logic is fully identical to the old implementation, with exception of the case where both of the operands had empty ranges:
``` TEST_F(ConstantRangeTest, CVP_UDiv) { unsigned Bits = 4; EnumerateConstantRanges(Bits, [&](const ConstantRange &CR0) { if(CR0.isEmptySet()) return; EnumerateConstantRanges(Bits, [&](const ConstantRange &CR1) { if(CR0.isEmptySet()) return;
unsigned MaxActiveBits = 0; for (const ConstantRange &CR : {CR0, CR1}) MaxActiveBits = std::max(MaxActiveBits, CR.getActiveBits());
ConstantRange OperandRange(Bits, /*isFullSet=*/false); for (const ConstantRange &CR : {CR0, CR1}) OperandRange = OperandRange.unionWith(CR); unsigned NewWidth = OperandRange.getUnsignedMax().getActiveBits();
EXPECT_EQ(MaxActiveBits, NewWidth) << CR0 << " " << CR1; }); }); } ```

 llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (diff) 

 llvm/include/llvm/ADT/APInt.h (diff) 
Commit
7465da2077c2b8def7440094e15ac1199226bc25
by lebedev.ri[ConstantRange] Introduce getMinSignedBits() method
Similar to the ConstantRange::getActiveBits(), and to similarlynamed methods in APInt, returns the bitwidth needed to represent the given signed constant range

 llvm/include/llvm/IR/ConstantRange.h (diff) 
 llvm/lib/IR/ConstantRange.cpp (diff) 
 llvm/unittests/IR/ConstantRangeTest.cpp (diff) 

 llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (diff) 

 llvm/test/Transforms/CorrelatedValuePropagation/sdiv.ll (diff) 
 llvm/test/Transforms/CorrelatedValuePropagation/srem.ll (diff) 
Commit
b289dc530632613edb3eb067895c1981cb77ccd0
by lebedev.ri[CVP] Narrow SDiv/SRem to the smallest powerof2 that's sufficient to contain its operands
This is practically identical to what we already do for UDiv/URem: https://rise4fun.com/Alive/04K
Name: narrow udiv Pre: C0 u<= 255 && C1 u<= 255 %r = udiv i16 C0, C1 => %t0 = trunc i16 C0 to i8 %t1 = trunc i16 C1 to i8 %t2 = udiv i8 %t0, %t1 %r = zext i8 %t2 to i16
Name: narrow exact udiv Pre: C0 u<= 255 && C1 u<= 255 %r = udiv exact i16 C0, C1 => %t0 = trunc i16 C0 to i8 %t1 = trunc i16 C1 to i8 %t2 = udiv exact i8 %t0, %t1 %r = zext i8 %t2 to i16
Name: narrow urem Pre: C0 u<= 255 && C1 u<= 255 %r = urem i16 C0, C1 => %t0 = trunc i16 C0 to i8 %t1 = trunc i16 C1 to i8 %t2 = urem i8 %t0, %t1 %r = zext i8 %t2 to i16
... only here we need to look for 'min signed bits', not 'active bits', and there's an UB to be aware of: https://rise4fun.com/Alive/KG86 https://rise4fun.com/Alive/LwR
Name: narrow sdiv Pre: C0 <= 127 && C1 <= 127 && C0 >= 128 && C1 >= 128 %r = sdiv i16 C0, C1 => %t0 = trunc i16 C0 to i9 %t1 = trunc i16 C1 to i9 %t2 = sdiv i9 %t0, %t1 %r = sext i9 %t2 to i16
Name: narrow exact sdiv Pre: C0 <= 127 && C1 <= 127 && C0 >= 128 && C1 >= 128 %r = sdiv exact i16 C0, C1 => %t0 = trunc i16 C0 to i9 %t1 = trunc i16 C1 to i9 %t2 = sdiv exact i9 %t0, %t1 %r = sext i9 %t2 to i16
Name: narrow srem Pre: C0 <= 127 && C1 <= 127 && C0 >= 128 && C1 >= 128 %r = srem i16 C0, C1 => %t0 = trunc i16 C0 to i9 %t1 = trunc i16 C1 to i9 %t2 = srem i9 %t0, %t1 %r = sext i9 %t2 to i16
Name: narrow sdiv Pre: C0 <= 127 && C1 <= 127 && C0 >= 128 && C1 >= 128 && !(C0 == 128 && C1 == 1) %r = sdiv i16 C0, C1 => %t0 = trunc i16 C0 to i8 %t1 = trunc i16 C1 to i8 %t2 = sdiv i8 %t0, %t1 %r = sext i8 %t2 to i16
Name: narrow exact sdiv Pre: C0 <= 127 && C1 <= 127 && C0 >= 128 && C1 >= 128 && !(C0 == 128 && C1 == 1) %r = sdiv exact i16 C0, C1 => %t0 = trunc i16 C0 to i8 %t1 = trunc i16 C1 to i8 %t2 = sdiv exact i8 %t0, %t1 %r = sext i8 %t2 to i16
Name: narrow srem Pre: C0 <= 127 && C1 <= 127 && C0 >= 128 && C1 >= 128 && !(C0 == 128 && C1 == 1) %r = srem i16 C0, C1 => %t0 = trunc i16 C0 to i8 %t1 = trunc i16 C1 to i8 %t2 = srem i8 %t0, %t1 %r = sext i8 %t2 to i16
The ConstantRangeTest.losslessSignedTruncationSignext test sanitychecks the logic, that we can losslessly truncate ConstantRange to `getMinSignedBits()` and signext it back, and it will be identical to the original CR.
On vanilla llvm testsuite + RawSpeed, this fires 1262 times, while the same fold for UDiv/URem only fires 384 times. Sic!
Additionally, this causes +606.18% (+1079) extra cases of aggressiveinstcombine.NumDAGsReduced, and +473.14% (+1145) of aggressiveinstcombine.NumInstrsReduced folds.

 llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (diff) 
 llvm/test/Transforms/CorrelatedValuePropagation/srem.ll (diff) 
 llvm/test/Transforms/CorrelatedValuePropagation/sdiv.ll (diff) 
Commit
fb1de7ed921c3c1531c0cb28b9603af22ecd0529
by joker.ephImplement a new kind of Pass: dynamic pass pipeline
Instead of performing a transformation, such pass yields a new pass pipeline to run on the currently visited operation. This feature can be used for example to implement a subpipeline that would run only on an operation with specific attributes. Another example would be to compute a cost model and dynamic schedule a pipeline based on the result of this analysis.
Discussion: https://llvm.discourse.group/t/rfcdynamicpasspipeline/1637
Recommit after fixing an ASAN issue: the callback lambda needs to be allocated to a temporary to have its lifetime extended to the end of the current block instead of just the current call expression.
Reviewed By: silvas
Differential Revision: https://reviews.llvm.org/D86392

 mlir/lib/Pass/Pass.cpp (diff) 
 mlir/test/Pass/dynamicpipelinefailonparent.mlir 
 mlir/test/lib/Transforms/CMakeLists.txt (diff) 
 mlir/include/mlir/Pass/Pass.h (diff) 
 mlir/test/Pass/dynamicpipelinenested.mlir 
 mlir/tools/mliropt/mliropt.cpp (diff) 
 mlir/include/mlir/Pass/PassManager.h (diff) 
 mlir/test/Pass/dynamicpipeline.mlir 
 mlir/test/lib/Transforms/TestDynamicPipeline.cpp 

 lldb/test/API/functionalities/asan/TestMemoryHistory.py (diff) 
Commit
2bc589bbb8d7d00f5939e9cd33cbe57e47d61f7e
by llvmproject[flang][msvc] Add explicit function template argument to applyFunction. NFC.
Msvc has difficulties deducing the template argument here. The error message is: ``` basicparsers.h(790,12): error C2672: 'applyFunction': no matching overloaded function found ``` Explicitly pass the first template argument to help it.
This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flangdev/2020July/000448.html>.
Reviewed By: DavidTruby
Differential Revision: https://reviews.llvm.org/D87961

 flang/lib/Parser/basicparsers.h (diff) 
Commit
97ca41e1ddfbb6812e2042dcbd2db6e0e7d0bc33
by llvmproject[flang][msvc] Add explicit function template argument to applyLamda. NFC.
Like in D87961, msvc has difficulties deducing the template argument. The error message is: ``` exprparsers.cpp(383): error C2672: 'applyLambda': no matching overloaded function found ``` Explicitly pass the first template argument to help it.
This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flangdev/2020July/000448.html>.
Reviewed By: DavidTruby
Differential Revision: https://reviews.llvm.org/D88001

 flang/lib/Parser/exprparsers.cpp (diff) 
Commit
62afc3129dc28638d950c17117347b4e001a613d
by llvmproject[flang][msvc] Explicitly reference "this" inside closure. NFC.
The Microsoft compiler seems to have difficulties to decide between a const/nonconst method of a captured object context in a closure. The error message is: ``` symbol.cpp(261): error C2668: 'Fortran::semantics::Symbol::detailsIf': ambiguous call to overloaded function symbol.h(535): note: could be 'const D *Fortran::semantics::Symbol::detailsIf<Fortran::semantics::DerivedTypeDetails>(void) const' symbol.h(534): note: or 'D *Fortran::semantics::Symbol::detailsIf<Fortran::semantics::DerivedTypeDetails>(void)' symbol.cpp(261): note: while trying to match the argument list '()' ``` Explicitly using the thispointer resolves this problem.
This patch is part of the series to make flang compilable with MS Visual Studio <http://lists.llvm.org/pipermail/flangdev/2020July/000448.html>.
Reviewed By: DavidTruby
Differential Revision: https://reviews.llvm.org/D88052

 flang/lib/Semantics/symbol.cpp (diff) 