[llvm-commits] [llvm] r76437 - in /llvm/trunk: include/llvm/Operator.h lib/Analysis/BasicAliasAnalysis.cpp lib/Analysis/ScalarEvolution.cpp lib/Transforms/Scalar/InstructionCombining.cpp lib/VMCore/Constants.cpp lib/VMCore/Instructions.cpp lib/VMCore/Value.cpp test/CodeGen/X86/iv-users-in-other-loops.ll test/Transforms/IndVarSimplify/max-pointer.ll test/Transforms/InstCombine/add2.ll test/Transforms/InstCombine/add3.ll test/Transforms/InstCombine/cast_ptr.ll

Dan Gohman gohman at apple.com
Mon Jul 20 10:43:31 PDT 2009


Author: djg
Date: Mon Jul 20 12:43:30 2009
New Revision: 76437

URL: http://llvm.org/viewvc/llvm-project?rev=76437&view=rev
Log:
Revert the addition of hasNoPointerOverflow to GEPOperator.
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.

Remove a few optimizations that depended on this flag.

Added:
    llvm/trunk/test/Transforms/InstCombine/add3.ll   (contents, props changed)
      - copied, changed from r76422, llvm/trunk/test/Transforms/InstCombine/add2.ll
Modified:
    llvm/trunk/include/llvm/Operator.h
    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/Instructions.cpp
    llvm/trunk/lib/VMCore/Value.cpp
    llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll
    llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll
    llvm/trunk/test/Transforms/InstCombine/add2.ll
    llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll

Modified: llvm/trunk/include/llvm/Operator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Operator.h?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Operator.h (original)
+++ llvm/trunk/include/llvm/Operator.h Mon Jul 20 12:43:30 2009
@@ -171,24 +171,6 @@
     return true;
   }
 
-  /// hasNoPointerOverflow - Return true if this GetElementPtr is known to
-  /// never have overflow in the pointer addition portions of its effective
-  /// computation. GetElementPtr computation involves several phases;
-  /// overflow can be considered to occur in index typecasting, array index
-  /// scaling, and the addition of the base pointer with offsets. This flag
-  /// only applies to the last of these. The operands are added to the base
-  /// pointer one at a time from left to right. This function returns false
-  /// if any of these additions results in an address value which is not
-  /// known to be within the allocated address space that the base pointer
-  /// points into, or within one element (of the original allocation) past
-  /// the end.
-  bool hasNoPointerOverflow() const {
-    return SubclassOptionalData & (1 << 0);
-  }
-  void setHasNoPointerOverflow(bool B) {
-    SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0);
-  }
-
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const GEPOperator *) { return true; }
   static inline bool classof(const GetElementPtrInst *) { return true; }

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Jul 20 12:43:30 2009
@@ -38,13 +38,8 @@
 // Useful predicates
 //===----------------------------------------------------------------------===//
 
-static const User *isGEP(const Value *V) {
-  if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V))
-    // For the purposes of BasicAliasAnalysis, if the GEP has overflow it
-    // could do crazy things.
-    if (GEP->hasNoPointerOverflow())
-      return GEP;
-  return 0;
+static const GEPOperator *isGEP(const Value *V) {
+  return dyn_cast<GEPOperator>(V);
 }
 
 static const Value *GetGEPOperands(const Value *V, 

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 20 12:43:30 2009
@@ -2938,15 +2938,10 @@
       return getSCEV(U->getOperand(0));
     break;
 
-  case Instruction::IntToPtr:
-    if (!TD) break; // Without TD we can't analyze pointers.
-    return getTruncateOrZeroExtend(getSCEV(U->getOperand(0)),
-                                   TD->getIntPtrType());
-
-  case Instruction::PtrToInt:
-    if (!TD) break; // Without TD we can't analyze pointers.
-    return getTruncateOrZeroExtend(getSCEV(U->getOperand(0)),
-                                   U->getType());
+    // It's tempting to handle inttoptr and ptrtoint, however this can
+    // lead to pointer expressions which cannot be expanded to GEPs
+    // (because they may overflow). For now, the only pointer-typed
+    // expressions we handle are GEPs and address literals.
 
   case Instruction::GetElementPtr:
     if (!TD) break; // Without TD we can't analyze pointers.

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 20 12:43:30 2009
@@ -2276,31 +2276,6 @@
         return R;
   }
 
-  // add (cast *A to intptrtype) B -> 
-  //   cast (GEP (cast *A to i8*) B)  -->  intptrtype
-  {
-    CastInst *CI = dyn_cast<CastInst>(LHS);
-    Value *Other = RHS;
-    if (!CI) {
-      CI = dyn_cast<CastInst>(RHS);
-      Other = LHS;
-    }
-    if (CI && CI->getType()->isSized() && 
-        (CI->getType()->getScalarSizeInBits() ==
-         TD->getIntPtrType()->getPrimitiveSizeInBits()) 
-        && isa<PointerType>(CI->getOperand(0)->getType())) {
-      unsigned AS =
-        cast<PointerType>(CI->getOperand(0)->getType())->getAddressSpace();
-      Value *I2 = InsertBitCastBefore(CI->getOperand(0),
-                                  Context->getPointerType(Type::Int8Ty, AS), I);
-      GetElementPtrInst *GEP = GetElementPtrInst::Create(I2, Other, "ctg2");
-      // A GEP formed from an arbitrary add may overflow.
-      cast<GEPOperator>(GEP)->setHasNoPointerOverflow(false);
-      I2 = InsertNewInstBefore(GEP, I);
-      return new PtrToIntInst(I2, CI->getType());
-    }
-  }
-  
   // add (select X 0 (sub n A)) A  -->  select X A n
   {
     SelectInst *SI = dyn_cast<SelectInst>(LHS);
@@ -8914,65 +8889,7 @@
   
   if (Instruction *I = commonCastTransforms(CI))
     return I;
-  
-  const Type *DestPointee = cast<PointerType>(CI.getType())->getElementType();
-  if (!DestPointee->isSized()) return 0;
 
-  // If this is inttoptr(add (ptrtoint x), cst), try to turn this into a GEP.
-  ConstantInt *Cst;
-  Value *X;
-  if (match(CI.getOperand(0), m_Add(m_Cast<PtrToIntInst>(m_Value(X)),
-                                    m_ConstantInt(Cst)), *Context)) {
-    // If the source and destination operands have the same type, see if this
-    // is a single-index GEP.
-    if (X->getType() == CI.getType()) {
-      // Get the size of the pointee type.
-      uint64_t Size = TD->getTypeAllocSize(DestPointee);
-
-      // Convert the constant to intptr type.
-      APInt Offset = Cst->getValue();
-      Offset.sextOrTrunc(TD->getPointerSizeInBits());
-
-      // If Offset is evenly divisible by Size, we can do this xform.
-      if (Size && !APIntOps::srem(Offset, APInt(Offset.getBitWidth(), Size))){
-        Offset = APIntOps::sdiv(Offset, APInt(Offset.getBitWidth(), Size));
-        GetElementPtrInst *GEP =
-          GetElementPtrInst::Create(X, Context->getConstantInt(Offset));
-        // A gep synthesized from inttoptr+add+ptrtoint must be assumed to
-        // potentially overflow, in the absense of further analysis.
-        cast<GEPOperator>(GEP)->setHasNoPointerOverflow(false);
-        return GEP;
-      }
-    }
-    // TODO: Could handle other cases, e.g. where add is indexing into field of
-    // struct etc.
-  } else if (CI.getOperand(0)->hasOneUse() &&
-             match(CI.getOperand(0), m_Add(m_Value(X),
-                   m_ConstantInt(Cst)), *Context)) {
-    // Otherwise, if this is inttoptr(add x, cst), try to turn this into an
-    // "inttoptr+GEP" instead of "add+intptr".
-    
-    // Get the size of the pointee type.
-    uint64_t Size = TD->getTypeAllocSize(DestPointee);
-    
-    // Convert the constant to intptr type.
-    APInt Offset = Cst->getValue();
-    Offset.sextOrTrunc(TD->getPointerSizeInBits());
-    
-    // If Offset is evenly divisible by Size, we can do this xform.
-    if (Size && !APIntOps::srem(Offset, APInt(Offset.getBitWidth(), Size))){
-      Offset = APIntOps::sdiv(Offset, APInt(Offset.getBitWidth(), Size));
-      
-      Instruction *P = InsertNewInstBefore(new IntToPtrInst(X, CI.getType(),
-                                                            "tmp"), CI);
-      GetElementPtrInst *GEP =
-        GetElementPtrInst::Create(P, Context->getConstantInt(Offset), "tmp");
-      // A gep synthesized from inttoptr+add+ptrtoint must be assumed to
-      // potentially overflow, in the absense of further analysis.
-      cast<GEPOperator>(GEP)->setHasNoPointerOverflow(false);
-      return GEP;
-    }
-  }
   return 0;
 }
 

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jul 20 12:43:30 2009
@@ -475,11 +475,8 @@
   static GetElementPtrConstantExpr *Create(Constant *C,
                                            const std::vector<Constant*>&IdxList,
                                            const Type *DestTy) {
-    GetElementPtrConstantExpr *Result = new(IdxList.size() + 1)
-      GetElementPtrConstantExpr(C, IdxList, DestTy);
-    // Getelementptr defaults to having no pointer overflow.
-    cast<GEPOperator>(Result)->setHasNoPointerOverflow(true);
-    return Result;
+    return
+      new(IdxList.size() + 1) GetElementPtrConstantExpr(C, IdxList, DestTy);
   }
   /// Transparently provide more efficient getOperand methods.
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Mon Jul 20 12:43:30 2009
@@ -1023,9 +1023,6 @@
     OL[i+1] = Idx[i];
 
   setName(Name);
-
-  // GetElementPtr instructions have undefined results on overflow by default.
-  cast<GEPOperator>(this)->setHasNoPointerOverflow(true);
 }
 
 void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) {
@@ -1035,9 +1032,6 @@
   OL[1] = Idx;
 
   setName(Name);
-
-  // GetElementPtr instructions have undefined results on overflow by default.
-  cast<GEPOperator>(this)->setHasNoPointerOverflow(true);
 }
 
 GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
@@ -1049,10 +1043,6 @@
   Use *GEPIOL = GEPI.OperandList;
   for (unsigned i = 0, E = NumOperands; i != E; ++i)
     OL[i] = GEPIOL[i];
-
-  // Transfer the hasNoPointerOverflow() value from the original GEPI.
-  cast<GEPOperator>(this)
-    ->setHasNoPointerOverflow(cast<GEPOperator>(GEPI).hasNoPointerOverflow());
 }
 
 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,

Modified: llvm/trunk/lib/VMCore/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Value.cpp?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Value.cpp (original)
+++ llvm/trunk/lib/VMCore/Value.cpp Mon Jul 20 12:43:30 2009
@@ -363,8 +363,6 @@
   unsigned MaxLookup = 6;
   do {
     if (GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
-      if (!GEP->hasNoPointerOverflow())
-        return V;
       V = GEP->getPointerOperand();
     } else if (Operator::getOpcode(V) == Instruction::BitCast) {
       V = cast<Operator>(V)->getOperand(0);

Modified: llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll (original)
+++ llvm/trunk/test/CodeGen/X86/iv-users-in-other-loops.ll Mon Jul 20 12:43:30 2009
@@ -3,8 +3,8 @@
 ; RUN: grep dec %t | count 2
 ; RUN: grep addq %t | count 13
 ; RUN: not grep addb %t
-; RUN: grep leaq %t | count 8
-; RUN: grep leal %t | count 4
+; RUN: grep leaq %t | count 9
+; RUN: grep leal %t | count 3
 ; RUN: grep movq %t | count 5
 
 ; IV users in each of the loops from other loops shouldn't cause LSR

Modified: llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll (original)
+++ llvm/trunk/test/Transforms/IndVarSimplify/max-pointer.ll Mon Jul 20 12:43:30 2009
@@ -22,58 +22,6 @@
 	ret void
 }
 
-define void @bar(i8* %str1Ptr, i64 %s, i8* %inLastBytePtr) nounwind {
-entry:
-        %str2Ptr = inttoptr i64 %s to i8*
-	%0 = icmp ult i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
-	%str2Ptr_addr.0 = select i1 %0, i8* %str1Ptr, i8* %str2Ptr		; <i8*> [#uses=1]
-	br label %bb2
-
-bb2:		; preds = %bb2, %entry
-	%str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ]		; <i8*> [#uses=1]
-	%1 = getelementptr i8* %str2Ptr_addr.1, i64 1		; <i8*> [#uses=2]
-	%2 = icmp ult i8* %1, %inLastBytePtr		; <i1> [#uses=0]
-	br i1 false, label %bb2, label %return
-
-return:		; preds = %bb2
-	ret void
-}
-
-define void @qux(i64 %t, i64 %s, i8* %inLastBytePtr) nounwind {
-entry:
-        %str1Ptr = inttoptr i64 %t to i8*
-        %str2Ptr = inttoptr i64 %s to i8*
-	%0 = icmp ult i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
-	%str2Ptr_addr.0 = select i1 %0, i8* %str1Ptr, i8* %str2Ptr		; <i8*> [#uses=1]
-	br label %bb2
-
-bb2:		; preds = %bb2, %entry
-	%str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ]		; <i8*> [#uses=1]
-	%1 = getelementptr i8* %str2Ptr_addr.1, i64 1		; <i8*> [#uses=2]
-	%2 = icmp ult i8* %1, %inLastBytePtr		; <i1> [#uses=0]
-	br i1 false, label %bb2, label %return
-
-return:		; preds = %bb2
-	ret void
-}
-
-define void @vor(i64 %t, i8* %str2Ptr, i8* %inLastBytePtr) nounwind {
-entry:
-        %str1Ptr = inttoptr i64 %t to i8*
-	%0 = icmp ult i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
-	%str2Ptr_addr.0 = select i1 %0, i8* %str1Ptr, i8* %str2Ptr		; <i8*> [#uses=1]
-	br label %bb2
-
-bb2:		; preds = %bb2, %entry
-	%str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ]		; <i8*> [#uses=1]
-	%1 = getelementptr i8* %str2Ptr_addr.1, i64 1		; <i8*> [#uses=2]
-	%2 = icmp ult i8* %1, %inLastBytePtr		; <i1> [#uses=0]
-	br i1 false, label %bb2, label %return
-
-return:		; preds = %bb2
-	ret void
-}
-
 define void @sfoo(i8* %str1Ptr, i8* %str2Ptr, i8* %inLastBytePtr) nounwind {
 entry:
 	%0 = icmp slt i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
@@ -89,57 +37,3 @@
 return:		; preds = %bb2
 	ret void
 }
-
-define void @sbar(i8* %str1Ptr, i64 %s, i8* %inLastBytePtr) nounwind {
-entry:
-        %str2Ptr = inttoptr i64 %s to i8*
-	%0 = icmp slt i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
-	%str2Ptr_addr.0 = select i1 %0, i8* %str1Ptr, i8* %str2Ptr		; <i8*> [#uses=1]
-	br label %bb2
-
-bb2:		; preds = %bb2, %entry
-	%str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ]		; <i8*> [#uses=1]
-	%1 = getelementptr i8* %str2Ptr_addr.1, i64 1		; <i8*> [#uses=2]
-	%2 = icmp slt i8* %1, %inLastBytePtr		; <i1> [#uses=0]
-	br i1 false, label %bb2, label %return
-
-return:		; preds = %bb2
-	ret void
-}
-
-define void @squx(i64 %t, i64 %s, i8* %inLastBytePtr) nounwind {
-entry:
-        %str1Ptr = inttoptr i64 %t to i8*
-        %str2Ptr = inttoptr i64 %s to i8*
-	%0 = icmp slt i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
-	%str2Ptr_addr.0 = select i1 %0, i8* %str1Ptr, i8* %str2Ptr		; <i8*> [#uses=1]
-	br label %bb2
-
-bb2:		; preds = %bb2, %entry
-	%str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ]		; <i8*> [#uses=1]
-	%1 = getelementptr i8* %str2Ptr_addr.1, i64 1		; <i8*> [#uses=2]
-	%2 = icmp slt i8* %1, %inLastBytePtr		; <i1> [#uses=0]
-	br i1 false, label %bb2, label %return
-
-return:		; preds = %bb2
-	ret void
-}
-
-define void @svor(i64 %t, i8* %str2Ptr, i8* %inLastBytePtr) nounwind {
-entry:
-        %str1Ptr = inttoptr i64 %t to i8*
-	%0 = icmp slt i8* %str2Ptr, %str1Ptr		; <i1> [#uses=1]
-	%str2Ptr_addr.0 = select i1 %0, i8* %str1Ptr, i8* %str2Ptr		; <i8*> [#uses=1]
-	br label %bb2
-
-bb2:		; preds = %bb2, %entry
-	%str2Ptr_addr.1 = phi i8* [ %str2Ptr_addr.0, %entry ], [ %1, %bb2 ]		; <i8*> [#uses=1]
-	%1 = getelementptr i8* %str2Ptr_addr.1, i64 1		; <i8*> [#uses=2]
-	%2 = icmp slt i8* %1, %inLastBytePtr		; <i1> [#uses=0]
-	br i1 false, label %bb2, label %return
-
-return:		; preds = %bb2
-	ret void
-}
-
-

Modified: llvm/trunk/test/Transforms/InstCombine/add2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/add2.ll?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/add2.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/add2.ll Mon Jul 20 12:43:30 2009
@@ -1,9 +1,4 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
-; RUN:    grep -v OK | not grep add
-
-;; Target triple for gep raising case below.
-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"
-target triple = "i686-apple-darwin8"
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep add
 
 define i64 @test1(i64 %A, i32 %B) {
         %tmp12 = zext i32 %B to i64
@@ -13,23 +8,6 @@
         ret i64 %tmp6
 }
 
-; PR1795
-define void @test2(i32 %.val24) {
-EntryBlock:
-        add i32 %.val24, -12
-        inttoptr i32 %0 to i32*
-        store i32 1, i32* %1
-        add i32 %.val24, -16
-        inttoptr i32 %2 to i32*
-        getelementptr i32* %3, i32 1
-        load i32* %4
-        tail call i32 @callee( i32 %5 )
-        ret void
-}
-
-declare i32 @callee(i32)
-
-
 define i32 @test3(i32 %A) {
   %B = and i32 %A, 7
   %C = and i32 %A, 32

Copied: llvm/trunk/test/Transforms/InstCombine/add3.ll (from r76422, llvm/trunk/test/Transforms/InstCombine/add2.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/add3.ll?p2=llvm/trunk/test/Transforms/InstCombine/add3.ll&p1=llvm/trunk/test/Transforms/InstCombine/add2.ll&r1=76422&r2=76437&rev=76437&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/add2.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/add3.ll Mon Jul 20 12:43:30 2009
@@ -1,18 +1,9 @@
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
-; RUN:    grep -v OK | not grep add
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep inttoptr | count 2
 
 ;; Target triple for gep raising case below.
 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"
 target triple = "i686-apple-darwin8"
 
-define i64 @test1(i64 %A, i32 %B) {
-        %tmp12 = zext i32 %B to i64
-        %tmp3 = shl i64 %tmp12, 32
-        %tmp5 = add i64 %tmp3, %A
-        %tmp6 = and i64 %tmp5, 123
-        ret i64 %tmp6
-}
-
 ; PR1795
 define void @test2(i32 %.val24) {
 EntryBlock:
@@ -28,19 +19,3 @@
 }
 
 declare i32 @callee(i32)
-
-
-define i32 @test3(i32 %A) {
-  %B = and i32 %A, 7
-  %C = and i32 %A, 32
-  %F = add i32 %B, %C
-  ret i32 %F
-}
-
-define i32 @test4(i32 %A) {
-  %B = and i32 %A, 128
-  %C = lshr i32 %A, 30
-  %F = add i32 %B, %C
-  ret i32 %F
-}
-

Propchange: llvm/trunk/test/Transforms/InstCombine/add3.ll

------------------------------------------------------------------------------
    cvs2svn:cvs-rev = 1.2

Propchange: llvm/trunk/test/Transforms/InstCombine/add3.ll

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: llvm/trunk/test/Transforms/InstCombine/add3.ll

------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: llvm/trunk/test/Transforms/InstCombine/add3.ll

------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll?rev=76437&r1=76436&r2=76437&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/cast_ptr.ll Mon Jul 20 12:43:30 2009
@@ -1,8 +1,15 @@
 ; Tests to make sure elimination of casts is working correctly
-; RUN: llvm-as < %s | opt -instcombine | llvm-dis | notcast
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | FileCheck %s
 
 target datalayout = "p:32:32"
 
+; This shouldn't convert to getelementptr because the relationship
+; between the arithmetic and the layout of allocated memory is
+; entirely unknown.
+; CHECK: @test1
+; CHECK: ptrtoint
+; CHECK: add
+; CHECK: inttoptr
 define i8* @test1(i8* %t) {
         %tmpc = ptrtoint i8* %t to i32          ; <i32> [#uses=1]
         %tmpa = add i32 %tmpc, 32               ; <i32> [#uses=1]
@@ -10,6 +17,9 @@
         ret i8* %tv
 }
 
+; These casts should be folded away.
+; CHECK: @test2
+; CHECK: icmp eq i8* %a, %b
 define i1 @test2(i8* %a, i8* %b) {
         %tmpa = ptrtoint i8* %a to i32          ; <i32> [#uses=1]
         %tmpb = ptrtoint i8* %b to i32          ; <i32> [#uses=1]





More information about the llvm-commits mailing list