llvm-project/llvm/lib/CodeGen/SelectionDAG
Roman Lebedev edfaee0811 [TargetLowering] x s% C == 0 fold: vector divisor with INT_MIN handling
Summary:
The general fold is only valid for positive divisors.
Which effectively means, it is invalid for `INT_MIN` divisors,
and we currently bailout if we see them.

But that is too strict, we can just fix-up the results.
For that, let's do a second computation 'in parallel':
```
Name: srem -> and
Pre: isPowerOf2(C)
%o = srem i8 %X, C
%r = icmp eq %o, 0
  =>
%n = and i8 %X, C-1
%r = icmp eq %n, 0
```
https://rise4fun.com/Alive/Sup

And then just blend results: if the divisor was `INT_MIN`,
pick the value we got via bit-test,
else pick the value from general fold.

There's interesting observation - `ISD::ROTR` is set to
`LegalizeAction::Expand` before AVX512, so we should not
treat `INT_MIN` divisor as even; and as it can be seen
while `@test_srem_odd_even_one` improves on all run-lines,
`@test_srem_odd_even_INT_MIN` only improves for AVX512.

Reviewers: RKSimon, craig.topper, spatel

Reviewed By: RKSimon

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66300

llvm-svn: 369268
2019-08-19 15:01:42 +00:00
..
CMakeLists.txt
DAGCombiner.cpp [DAGCombiner] Add simple folds for SMULFIX/UMULFIX/SMULFIXSAT 2019-08-16 13:16:48 +00:00
FastISel.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
FunctionLoweringInfo.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
InstrEmitter.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
InstrEmitter.h [SelectionDAG] Enhance the simplification of `copyto` from `implicit-def`. 2019-05-27 18:26:29 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
LegalizeDAG.cpp [Strict FP] Allow custom operation actions 2019-08-06 10:43:13 +00:00
LegalizeFloatTypes.cpp AMDGPU: Correct behavior of f16 buffer loads 2019-08-05 15:59:07 +00:00
LegalizeIntegerTypes.cpp [SelectionDAG] Extend base addressing modes supported by MGATHER/MSCATTER 2019-08-06 09:46:13 +00:00
LegalizeTypes.cpp Propagate fmf for setcc in SDAG for select folds 2019-06-03 21:53:26 +00:00
LegalizeTypes.h [SelectionDAG] Widen vector results of SMULFIX/UMULFIX/SMULFIXSAT 2019-08-11 19:27:06 +00:00
LegalizeTypesGeneric.cpp [LegalizeTypes] Remove SplitVSETCC helper and just call SplitVecRes_SETCC. 2019-08-08 21:13:58 +00:00
LegalizeVectorOps.cpp [SelectionDAG] Widen vector results of SMULFIX/UMULFIX/SMULFIXSAT 2019-08-11 19:27:06 +00:00
LegalizeVectorTypes.cpp [SelectionDAG] Widen vector results of SMULFIX/UMULFIX/SMULFIXSAT 2019-08-11 19:27:06 +00:00
ResourcePriorityQueue.cpp Implementation of asm-goto support in LLVM 2019-02-08 20:48:56 +00:00
SDNodeDbgValue.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScheduleDAGFast.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
ScheduleDAGRRList.cpp Finish moving TargetRegisterInfo::isVirtualRegister() and friends to llvm::Register as started by r367614. NFC 2019-08-01 23:27:28 +00:00
ScheduleDAGSDNodes.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
ScheduleDAGSDNodes.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScheduleDAGVLIW.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SelectionDAG.cpp [SelectionDAG] Add a node creation debug message to getMachineNode. 2019-08-18 06:28:00 +00:00
SelectionDAGAddressAnalysis.cpp [DAGCombiner] Unify Lifetime and memory Op aliasing. 2019-03-27 14:14:46 +00:00
SelectionDAGBuilder.cpp Apply llvm-prefer-register-over-unsigned from clang-tidy to LLVM 2019-08-15 19:22:08 +00:00
SelectionDAGBuilder.h [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
SelectionDAGDumper.cpp [CodeGen] Add lrint/llrint builtins 2019-05-28 20:47:44 +00:00
SelectionDAGISel.cpp [llvm] Migrate llvm::make_unique to std::make_unique 2019-08-15 15:54:37 +00:00
SelectionDAGPrinter.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SelectionDAGTargetInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
StatepointLowering.cpp [Statepoints] Fix overalignment of loads in no-realign-stack functions 2019-08-02 20:17:37 +00:00
StatepointLowering.h [FastISel] Fix crash for gc.relocate lowring 2019-04-05 05:41:08 +00:00
TargetLowering.cpp [TargetLowering] x s% C == 0 fold: vector divisor with INT_MIN handling 2019-08-19 15:01:42 +00:00