1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 @g = external global i16, align 1
5 @g2 = external global i16, align 1
7 define i64 @ptrdiff1() {
8 ; CHECK-LABEL: @ptrdiff1(
9 ; CHECK-NEXT: ret i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
11 %i = ptrtoint i16* @g to i64
12 %i2 = ptrtoint i16* @g2 to i64
13 %diff = sub i64 %i, %i2
18 define i64 @ptrdiff2() {
19 ; CHECK-LABEL: @ptrdiff2(
20 ; CHECK-NEXT: ret i64 -2
22 %i = ptrtoint i16* @g to i64
23 %gep = getelementptr i16, i16* @g, i64 1
24 %i2 = ptrtoint i16* %gep to i64
25 %diff = sub i64 %i, %i2