[llvm] 02dadab - NFC; add an example that subtracts pointers to two global vars

Juneyoung Lee via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 26 04:47:56 PDT 2020


Author: Juneyoung Lee
Date: 2020-07-26T20:47:33+09:00
New Revision: 02dadab1b459a3ed4f440b2de3ab21eba7bd5a2e

URL: https://github.com/llvm/llvm-project/commit/02dadab1b459a3ed4f440b2de3ab21eba7bd5a2e
DIFF: https://github.com/llvm/llvm-project/commit/02dadab1b459a3ed4f440b2de3ab21eba7bd5a2e.diff

LOG: NFC; add an example that subtracts pointers to two global vars

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/freeze.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/freeze.ll b/llvm/test/Transforms/InstSimplify/freeze.ll
index 3c4ca7a1afb9..3aa77854f602 100644
--- a/llvm/test/Transforms/InstSimplify/freeze.ll
+++ b/llvm/test/Transforms/InstSimplify/freeze.ll
@@ -111,8 +111,7 @@ define <2 x float> @constvector_FP_noopt() {
 }
 
 @g = external global i16, align 1
-
-; Negative test
+ at g2 = external global i16, align 1
 
 define float @constant_expr() {
 ; CHECK-LABEL: @constant_expr(
@@ -138,6 +137,18 @@ define i32* @constant_expr3() {
   ret i32* %r
 }
 
+define i64 @ptr
diff () {
+; CHECK-LABEL: @ptr
diff (
+; 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() {


        


More information about the llvm-commits mailing list