; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s @g = external global i16, align 1 @g2 = external global i16, align 1 define i64 @ptrdiff1() { ; CHECK-LABEL: @ptrdiff1( ; CHECK-NEXT: ret i64 sub (i64 ptrtoint (ptr @g to i64), i64 ptrtoint (ptr @g2 to i64)) ; %i = ptrtoint ptr @g to i64 %i2 = ptrtoint ptr @g2 to i64 %diff = sub i64 %i, %i2 %r = freeze i64 %diff ret i64 %r } define i64 @ptrdiff2() { ; CHECK-LABEL: @ptrdiff2( ; CHECK-NEXT: ret i64 -2 ; %i = ptrtoint ptr @g to i64 %gep = getelementptr i16, ptr @g, i64 1 %i2 = ptrtoint ptr %gep to i64 %diff = sub i64 %i, %i2 %r = freeze i64 %diff ret i64 %r }