]> granicus.if.org Git - clang/commitdiff
Clang part of r69947. Reverting back 69574 as it is no longer needed.
authorSanjiv Gupta <sanjiv.gupta@microchip.com>
Fri, 24 Apr 2009 02:40:57 +0000 (02:40 +0000)
committerSanjiv Gupta <sanjiv.gupta@microchip.com>
Fri, 24 Apr 2009 02:40:57 +0000 (02:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69949 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprScalar.cpp

index ed1baa0da0ad3f5086327f4a8c9650dfa4d357e1..f155139e517950cb10d1a5b317fef85ef9ae4aab 100644 (file)
@@ -805,11 +805,8 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
   QualType IdxTy  = E->getIdx()->getType();
   bool IdxSigned = IdxTy->isSignedIntegerType();
   unsigned IdxBitwidth = cast<llvm::IntegerType>(Idx->getType())->getBitWidth();
-  
-  // If Pointer width is less than 32 than extend to 32.
-  unsigned IdxValidWidth = (LLVMPointerWidth < 32 ) ? 32 : LLVMPointerWidth;
-  if (IdxBitwidth != IdxValidWidth)
-    Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(IdxValidWidth),
+  if (IdxBitwidth != LLVMPointerWidth)
+    Idx = Builder.CreateIntCast(Idx, llvm::IntegerType::get(LLVMPointerWidth),
                                 IdxSigned, "idxprom");
 
   // We know that the pointer points to a type of the correct size, unless the
index 77771bd937a894aa79da194ef0ec8f3d6a314874..308a45e43355f69679d856b53199db4ad49849f4 100644 (file)
@@ -958,14 +958,10 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
   }
 
   unsigned Width = cast<llvm::IntegerType>(Idx->getType())->getBitWidth();
-  // Only 32 and 64 are valid index widths. So if a target has shorter 
-  // pointe width, extend to 32 at least.
-  unsigned IdxValidWidth 
-    = (CGF.LLVMPointerWidth < 32) ? 32 : CGF.LLVMPointerWidth;
-  if (Width < IdxValidWidth) {
+  if (Width < CGF.LLVMPointerWidth) {
     // Zero or sign extend the pointer value based on whether the index is
     // signed or not.
-    const llvm::Type *IdxType = llvm::IntegerType::get(IdxValidWidth);
+    const llvm::Type *IdxType = llvm::IntegerType::get(CGF.LLVMPointerWidth);
     if (IdxExp->getType()->isSignedIntegerType())
       Idx = Builder.CreateSExt(Idx, IdxType, "idx.ext");
     else
@@ -1008,12 +1004,10 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
     // pointer - int
     Value *Idx = Ops.RHS;
     unsigned Width = cast<llvm::IntegerType>(Idx->getType())->getBitWidth();
-    unsigned IdxValidWidth 
-      = (CGF.LLVMPointerWidth < 32) ? 32 : CGF.LLVMPointerWidth;
-    if (Width < IdxValidWidth) {
+    if (Width < CGF.LLVMPointerWidth) {
       // Zero or sign extend the pointer value based on whether the index is
       // signed or not.
-      const llvm::Type *IdxType = llvm::IntegerType::get(IdxValidWidth);
+      const llvm::Type *IdxType = llvm::IntegerType::get(CGF.LLVMPointerWidth);
       if (Ops.E->getRHS()->getType()->isSignedIntegerType())
         Idx = Builder.CreateSExt(Idx, IdxType, "idx.ext");
       else