diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index f473cf5ca54..9f36a386917 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -361,8 +361,10 @@ static bool isCompleteOverwrite(const AliasAnalysis::Location &Later, // // |--earlier--| // |----- later ------| + // + // We have to be careful here as *Off is signed while *.Size is unsigned. if (EarlierOff >= LaterOff && - EarlierOff + Earlier.Size <= LaterOff + Later.Size) + uint64_t(EarlierOff - LaterOff) + Earlier.Size <= Later.Size) return true; // Otherwise, they don't completely overlap. diff --git a/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll b/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll index e268dd54140..079eec43bf8 100644 --- a/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll +++ b/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll @@ -1,5 +1,6 @@ ; RUN: opt < %s -basicaa -dse -S | FileCheck %s ; PR9561 +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" target triple = "i386-apple-darwin9.8" @A = external global [0 x i32]