diff options
author | James Molloy <james.molloy@arm.com> | 2015-05-17 08:27:27 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2015-05-17 08:27:27 +0000 |
commit | 53958e187a624142498f42d4a67a8e64b65b1c6c (patch) | |
tree | a637b90f0766abb83148286e028b5d4f8aa4df55 /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | |
parent | 0928553eecaa835b9983c8afbc8ee3948327a06c (diff) | |
download | llvm-53958e187a624142498f42d4a67a8e64b65b1c6c.zip llvm-53958e187a624142498f42d4a67a8e64b65b1c6c.tar.gz llvm-53958e187a624142498f42d4a67a8e64b65b1c6c.tar.bz2 |
Reapply r237520 with another fix for infinite looping
SimplifyDemandedBits was "simplifying" a constant by removing just sign bits.
This caused a canonicalization race between different parts of instcombine.
Fix and regression test added - third time lucky?
llvm-svn: 237539
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 9c2bc34..48ab0eb 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -435,6 +435,15 @@ Instruction *InstCombiner::visitTrunc(TruncInst &CI) { if (Instruction *Result = commonCastTransforms(CI)) return Result; + // Test if the trunc is the user of a select which is part of a + // minimum or maximum operation. If so, don't do any more simplification. + // Even simplifying demanded bits can break the canonical form of a + // min/max. + Value *LHS, *RHS; + if (SelectInst *SI = dyn_cast<SelectInst>(CI.getOperand(0))) + if (matchSelectPattern(SI, LHS, RHS) != SPF_UNKNOWN) + return nullptr; + // See if we can simplify any instructions used by the input whose sole // purpose is to compute bits we don't care about. if (SimplifyDemandedInstructionBits(CI)) |