aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-14 20:57:04 +0000
committerDan Gohman <gohman@apple.com>2009-07-14 20:57:04 +0000
commit0196dc5733bf3c6a71f7de1f631f2c43e5809fd9 (patch)
tree6b7e3786656e5491bab100fe2ab41202520fbb5b /test
parent001c2b433fd7fc30904abb4eafc78ac996430fe6 (diff)
downloadexternal_llvm-0196dc5733bf3c6a71f7de1f631f2c43e5809fd9.zip
external_llvm-0196dc5733bf3c6a71f7de1f631f2c43e5809fd9.tar.gz
external_llvm-0196dc5733bf3c6a71f7de1f631f2c43e5809fd9.tar.bz2
Fix the expansion of umax and smax in the case where one or more of
the operands have pointer type, so that the resulting type matches the original SCEV type, and so that unnecessary ptrtoints are avoided in common cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75680 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/IndVarSimplify/max-pointer.ll145
1 files changed, 145 insertions, 0 deletions
diff --git a/test/Transforms/IndVarSimplify/max-pointer.ll b/test/Transforms/IndVarSimplify/max-pointer.ll
new file mode 100644
index 0000000..ba2b2fa
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/max-pointer.ll
@@ -0,0 +1,145 @@
+; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t
+; RUN: grep {icmp ugt i8\\\*} %t | count 1
+; RUN: grep {icmp sgt i8\\\*} %t | count 1
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
+
+ %struct.CKenCodeCodec = type <{ i8 }>
+
+define void @foo(i8* %str1Ptr, i8* %str2Ptr, i8* %inLastBytePtr) nounwind {
+entry:
+ %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 @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]
+ %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 @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
+}
+
+