Skip to content

Commit

Permalink
NFC; add an example that subtracts pointers to two global vars
Browse files Browse the repository at this point in the history
  • Loading branch information
aqjune committed Jul 26, 2020
1 parent b1210c0 commit 02dadab
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions llvm/test/Transforms/InstSimplify/freeze.ll
Expand Up @@ -111,8 +111,7 @@ define <2 x float> @constvector_FP_noopt() {
}

@g = external global i16, align 1

; Negative test
@g2 = external global i16, align 1

define float @constant_expr() {
; CHECK-LABEL: @constant_expr(
Expand All @@ -138,6 +137,18 @@ define i32* @constant_expr3() {
ret i32* %r
}

define i64 @ptrdiff() {
; CHECK-LABEL: @ptrdiff(
; CHECK-NEXT: [[R:%.*]] = freeze i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
; CHECK-NEXT: ret i64 [[R]]
;
%i = ptrtoint i16* @g to i64
%i2 = ptrtoint i16* @g2 to i64
%diff = sub i64 %i, %i2
%r = freeze i64 %diff
ret i64 %r
}

; Negative test

define <2 x i31> @vector_element_constant_expr() {
Expand Down

0 comments on commit 02dadab

Please sign in to comment.