LoopVectorize: Vectorize all accesses in address space zero with unit stride
[oota-llvm.git] / test / Transforms / InstSimplify / ptr_diff.ll
index 86516280696a93df762ba4afdc7ee4802c5718ad..8b4aa796013bc20175522be46e63843c6f29a948 100644 (file)
@@ -57,3 +57,22 @@ define <4 x i32> @ptrdiff4(<4 x i8*> %arg) nounwind {
   %sub = sub <4 x i32> %p1, %p2
   ret <4 x i32> %sub
 }
+
+%struct.ham = type { i32, [2 x [2 x i32]] }
+
+@global = internal global %struct.ham zeroinitializer, align 4
+
+define i32 @ptrdiff5() nounwind {
+bb:
+  %tmp = getelementptr inbounds %struct.ham* @global, i32 0, i32 1
+  %tmp1 = getelementptr inbounds [2 x [2 x i32]]* %tmp, i32 0, i32 0
+  %tmp2 = bitcast [2 x i32]* %tmp1 to i32*
+  %tmp3 = ptrtoint i32* %tmp2 to i32
+  %tmp4 = getelementptr inbounds %struct.ham* @global, i32 0, i32 1
+  %tmp5 = getelementptr inbounds [2 x [2 x i32]]* %tmp4, i32 0, i32 0
+  %tmp6 = ptrtoint [2 x i32]* %tmp5 to i32
+  %tmp7 = sub i32 %tmp3, %tmp6
+  ret i32 %tmp7
+; CHECK: @ptrdiff5
+; CHECK: ret i32 0
+}