summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2019-11-30 14:20:55 +0000
committerDavid Green <david.green@arm.com>2019-11-30 16:58:00 +0000
commit3a1bef5616c3eb466b5f8a076385ee09e5a9ad9a (patch)
tree8679997f135350af218461b587b98a58961ea8c5 /llvm/lib/Transforms
parenta46b959ebd605e9dc4bc0e041dac3bdf2f3d8989 (diff)
downloadbcm5719-llvm-3a1bef5616c3eb466b5f8a076385ee09e5a9ad9a.tar.gz
bcm5719-llvm-3a1bef5616c3eb466b5f8a076385ee09e5a9ad9a.zip
[InstCombine] Adjust usub_sat fold one use checks
This adjusts the one use checks in the the usub_sat fold code to not increase instruction count, but otherwise do the fold. Reviewed as a part of D69514.
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index bdfbd75d31a..0b6b7c3c66d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -711,9 +711,9 @@ static Value *canonicalizeSaturatedSubtract(const ICmpInst *ICI,
else if (!match(TrueVal, m_Sub(m_Specific(A), m_Specific(B))))
return nullptr;
- // If sub is used anywhere else, we wouldn't be able to eliminate it
- // afterwards.
- if (!TrueVal->hasOneUse())
+ // If we are adding a negate and the sub and icmp are used anywhere else, we
+ // would end up with more instructions.
+ if (IsNegative && !TrueVal->hasOneUse() && !ICI->hasOneUse())
return nullptr;
// (a > b) ? a - b : 0 -> usub.sat(a, b)
OpenPOWER on IntegriCloud