diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2007-09-06 02:40:25 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2007-09-06 02:40:25 +0000 |
commit | 2de09a965fba2fdf01cc6272c2d7f9b720e93f6c (patch) | |
tree | ec8b58119d012bb5694de246fa10bee366bcb8f9 /lib/Transforms | |
parent | 2bae87261a939f60238169d581da6ef61a7abd81 (diff) | |
download | external_llvm-2de09a965fba2fdf01cc6272c2d7f9b720e93f6c.zip external_llvm-2de09a965fba2fdf01cc6272c2d7f9b720e93f6c.tar.gz external_llvm-2de09a965fba2fdf01cc6272c2d7f9b720e93f6c.tar.bz2 |
Use isTrueWhenEqual. Thanks Chris!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41741 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 58eb3bc..4902fb7 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1663,16 +1663,22 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, uint64_t DemandedElts, return MadeChange ? I : 0; } -/// @returns true if the specified compare instruction is +/// @returns true if the specified compare predicate is /// true when both operands are equal... -/// @brief Determine if the ICmpInst returns true if both operands are equal -static bool isTrueWhenEqual(ICmpInst &ICI) { - ICmpInst::Predicate pred = ICI.getPredicate(); +/// @brief Determine if the icmp Predicate is true when both operands are equal +static bool isTrueWhenEqual(ICmpInst::Predicate pred) { return pred == ICmpInst::ICMP_EQ || pred == ICmpInst::ICMP_UGE || pred == ICmpInst::ICMP_SGE || pred == ICmpInst::ICMP_ULE || pred == ICmpInst::ICMP_SLE; } +/// @returns true if the specified compare instruction is +/// true when both operands are equal... +/// @brief Determine if the ICmpInst returns true when both operands are equal +static bool isTrueWhenEqual(ICmpInst &ICI) { + return isTrueWhenEqual(ICI.getPredicate()); +} + /// AssociativeOpt - Perform an optimization on an associative operator. This /// function is designed to check a chain of associative operators for a /// potential to apply a certain optimization. Since the optimization may be @@ -4562,10 +4568,9 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS, if (NumDifferences == 0) // SAME GEP? return ReplaceInstUsesWith(I, // No comparison is needed here. - ConstantInt::get(Type::Int1Ty, - Cond == ICmpInst::ICMP_EQ || - Cond == ICmpInst::ICMP_ULE || Cond == ICmpInst::ICMP_UGE || - Cond == ICmpInst::ICMP_SLE || Cond == ICmpInst::ICMP_SGE)); + ConstantInt::get(Type::Int1Ty, + isTrueWhenEqual(Cond))); + else if (NumDifferences == 1) { Value *LHSV = GEPLHS->getOperand(DiffOperand); Value *RHSV = GEPRHS->getOperand(DiffOperand); |