llvm-project/llvm/lib/Transforms/InstCombine
Roman Lebedev 6dc87004fa [InstCombine] Inefficient pattern for high-bits checking 2 (PR38708)
Summary:
It is sometimes important to check that some newly-computed value
is non-negative and only n bits wide (where n is a variable.)
There are many ways to check that:
https://godbolt.org/z/o4RB8D
The last variant seems best?
(I'm sure there are some other variations i haven't thought of..)

More complicated, canonical pattern:
https://rise4fun.com/Alive/uhA

We do need to have two `switch()`'es like this,
to not mismatch the swappable predicates.

https://bugs.llvm.org/show_bug.cgi?id=38708

Reviewers: spatel, craig.topper, RKSimon

Reviewed By: spatel

Subscribers: llvm-commits

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

llvm-svn: 342173
2018-09-13 20:33:12 +00:00
..
CMakeLists.txt InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineAddSub.cpp [InstCombine] Use dyn_cast instead of match(m_Constant). NFC 2018-09-11 16:51:26 +00:00
InstCombineAndOrXor.cpp [InstCombine] Fold (xor (min/max X, Y), -1) -> (max/min ~X, ~Y) when X and Y are freely invertible. 2018-09-13 18:52:58 +00:00
InstCombineCalls.cpp [InstCombine] canonicalize fneg with llvm.sin 2018-08-29 18:27:49 +00:00
InstCombineCasts.cpp Fix InstCombine address space assert 2018-07-31 15:53:03 +00:00
InstCombineCompares.cpp [InstCombine] Inefficient pattern for high-bits checking 2 (PR38708) 2018-09-13 20:33:12 +00:00
InstCombineInternal.h [InstCombine] Add splat vector constant support to foldICmpAddOpConst. 2018-08-20 23:04:25 +00:00
InstCombineLoadStoreAlloca.cpp [Local] Make DoesKMove required for combineMetadata. 2018-08-24 11:40:04 +00:00
InstCombineMulDivRem.cpp [InstCombine] Fix incorrect usage of getPrimitiveSizeInBits when we should be using the element size for vectors 2018-09-11 17:57:20 +00:00
InstCombinePHI.cpp [IR] Replace `isa<TerminatorInst>` with `isTerminator()`. 2018-08-26 09:51:22 +00:00
InstCombineSelect.cpp [InstCombine] Fold (xor (min/max X, Y), -1) -> (max/min ~X, ~Y) when X and Y are freely invertible. 2018-09-13 18:52:58 +00:00
InstCombineShifts.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
InstCombineSimplifyDemanded.cpp [InstCombine] enhance vector demanded elements to look at a vector select condition operand 2018-09-11 18:49:00 +00:00
InstCombineTables.td InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineVectorOps.cpp [InstCombine] narrow vector select with padded condition and extracted result (PR38691) 2018-09-07 21:03:34 +00:00
InstructionCombining.cpp [InstCombine] allow shuffle+binop canonicalization with widening shuffles 2018-08-27 22:41:44 +00:00
LLVMBuild.txt