4410950db6
This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/llvm.git#f768ecb72d51ac2181cf867dcb39b3171c9c057a
26 lines
1.3 KiB
Diff
26 lines
1.3 KiB
Diff
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
|
|
index cf02ef1e83f3..e370f8c34809 100644
|
|
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
|
|
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
|
|
@@ -3885,8 +3885,8 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
|
|
// Check that the multiplication doesn't overflow.
|
|
if (Base.BaseOffset == std::numeric_limits<int64_t>::min() && Factor == -1)
|
|
continue;
|
|
- int64_t NewBaseOffset = (uint64_t)Base.BaseOffset * Factor;
|
|
- if (NewBaseOffset / Factor != Base.BaseOffset)
|
|
+ int64_t NewBaseOffset;
|
|
+ if(__builtin_mul_overflow(Base.BaseOffset, Factor, &NewBaseOffset))
|
|
continue;
|
|
// If the offset will be truncated at this use, check that it is in bounds.
|
|
if (!IntTy->isPointerTy() &&
|
|
@@ -3897,8 +3897,7 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
|
|
int64_t Offset = LU.MinOffset;
|
|
if (Offset == std::numeric_limits<int64_t>::min() && Factor == -1)
|
|
continue;
|
|
- Offset = (uint64_t)Offset * Factor;
|
|
- if (Offset / Factor != LU.MinOffset)
|
|
+ if(__builtin_mul_overflow(Offset, Factor, &Offset))
|
|
continue;
|
|
// If the offset will be truncated at this use, check that it is in bounds.
|
|
if (!IntTy->isPointerTy() &&
|