Extension of GEP in constant folder was broken (apparently this code
authorDaniel Dunbar <daniel@zuster.org>
Tue, 24 Feb 2009 19:10:46 +0000 (19:10 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 24 Feb 2009 19:10:46 +0000 (19:10 +0000)
has never been run!).
 - Sorry, don't know how to make an LLVM test case for this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65383 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/ConstantFold.cpp

index ff4d897e54a8b945d1d49ff959a424f49452b943..f2847112afcb265539977e434c5b48cbe2f0e6fc 100644 (file)
@@ -1664,7 +1664,7 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C,
         Offset = ConstantExpr::getSExt(Offset, Base->getType());
       else if (Base->getType()->getPrimitiveSizeInBits() <
                Offset->getType()->getPrimitiveSizeInBits())
-        Base = ConstantExpr::getZExt(Base, Base->getType());
+        Base = ConstantExpr::getZExt(Base, Offset->getType());
       
       Base = ConstantExpr::getAdd(Base, Offset);
       return ConstantExpr::getIntToPtr(Base, CE->getType());