llvm-project/llvm/lib/Transforms/InstCombine
Sanjay Patel baffae91b2 [InstCombine] simplify icmps with same operands based on dominating cmp
The tests here are based on the motivating cases from D54827.

More background:
1. We don't get these cases in general with SimplifyCFG because the root
   of the pattern match is an icmp, not a branch. I'm not sure how often
   we encounter this pattern vs. the seemingly more likely case with 
   branches, but I don't see evidence to leave the minimal pattern
   unoptimized.

2. This has a chance of increasing compile-time because we're using a
   ValueTracking call to handle the match. The motivating cases could be
   handled with a simpler pair of calls to isImpliedTrueByMatchingCmp/
   isImpliedFalseByMatchingCmp, but I saw that we have a more 
   comprehensive wrapper around those, so we might as well use it here
   unless there's evidence that it's significantly slower.

3. Ideally, we'd handle the fold to constants in InstSimplify, but as
   with the existing code here, we could extend this to handle cases
   where the result is not a constant, but a new combined predicate.
   That would mean splitting the logic across the 2 passes and possibly
   duplicating the pattern-matching cost.

4. As mentioned in D54827, this seems like the kind of thing that should
   be handled in Correlated Value Propagation, but that pass is currently
   limited to dealing with instructions with constant operands, so extending
   this bit of InstCombine is the smallest/easiest way to get these patterns 
   optimized.

llvm-svn: 348367
2018-12-05 15:04:00 +00:00
..
CMakeLists.txt InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineAddSub.cpp [InstCombine] name change: foldShuffledBinop -> foldVectorBinop; NFC 2018-10-03 15:20:58 +00:00
InstCombineAndOrXor.cpp [CmpInstAnalysis] fix function signature for ICmp code to predicate; NFC 2018-12-04 18:53:27 +00:00
InstCombineCalls.cpp [InstCombine] Support ssub.sat canonicalization for non-splats 2018-12-01 10:58:34 +00:00
InstCombineCasts.cpp [InstCombine] fix rotate narrowing bug for non-pow-2 types 2018-11-15 17:19:14 +00:00
InstCombineCompares.cpp [InstCombine] simplify icmps with same operands based on dominating cmp 2018-12-05 15:04:00 +00:00
InstCombineInternal.h [InstCombine] add helper for icmp with dominator; NFC 2018-12-04 15:35:17 +00:00
InstCombineLoadStoreAlloca.cpp [InstCombine] Set debug loc on `mergeStoreIntoSuccessor` phi 2018-11-19 19:55:02 +00:00
InstCombineMulDivRem.cpp Add a emitUnaryFloatFnCall version that fetches the function name from TLI 2018-10-18 06:27:53 +00:00
InstCombinePHI.cpp Use llvm::{all,any,none}_of instead std::{all,any,none}_of. NFC 2018-10-19 06:12:02 +00:00
InstCombineSelect.cpp [InstSimplify] fold select with implied condition 2018-11-29 18:44:39 +00:00
InstCombineShifts.cpp [InstCombine] Ensure nested shifts are in range (OSS-Fuzz #9880) 2018-11-06 11:28:22 +00:00
InstCombineSimplifyDemanded.cpp Revert r347871 "Fix: Add support for TFE/LWE in image intrinsic" 2018-11-29 20:14:17 +00:00
InstCombineTables.td InstCombine/AMDGPU: Add dimension-aware image intrinsics to SimplifyDemanded 2018-06-21 13:37:31 +00:00
InstCombineVectorOps.cpp [InstCombine] try to turn shuffle into insertelement 2018-10-30 15:26:39 +00:00
InstructionCombining.cpp [InstCombine] fix undef propagation bug with shuffle+binop 2018-12-03 21:15:17 +00:00
LLVMBuild.txt