[llvm-commits] [llvm] r128577 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll

Bill Wendling isanbard at gmail.com
Wed Mar 30 14:37:19 PDT 2011


Author: void
Date: Wed Mar 30 16:37:19 2011
New Revision: 128577

URL: http://llvm.org/viewvc/llvm-project?rev=128577&view=rev
Log:
* The DSE code that tested for overlapping needed to take into account the fact
  that one of the numbers is signed while the other is unsigned. This could lead
  to a wrong result when the signed was promoted to an unsigned int.

* Add the data layout line to the testcase so that it will test the appropriate
  thing.

Patch by David Terei!

Modified:
    llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
    llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128577&r1=128576&r2=128577&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Mar 30 16:37:19 2011
@@ -361,8 +361,10 @@
   //
   //        |--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.

Modified: llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll?rev=128577&r1=128576&r2=128577&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll (original)
+++ llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll Wed Mar 30 16:37:19 2011
@@ -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]





More information about the llvm-commits mailing list