[llvm] 1b802fe - NFC; add a test for freeze's constprop

Juneyoung Lee via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 26 05:03:38 PDT 2020


Author: Juneyoung Lee
Date: 2020-07-26T21:03:23+09:00
New Revision: 1b802fe34d716f2a3542fad3e8ba74f77685590d

URL: https://github.com/llvm/llvm-project/commit/1b802fe34d716f2a3542fad3e8ba74f77685590d
DIFF: https://github.com/llvm/llvm-project/commit/1b802fe34d716f2a3542fad3e8ba74f77685590d.diff

LOG: NFC; add a test for freeze's constprop

Added: 
    llvm/test/Analysis/ConstantFolding/freeze.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/ConstantFolding/freeze.ll b/llvm/test/Analysis/ConstantFolding/freeze.ll
new file mode 100644
index 000000000000..c2da04130845
--- /dev/null
+++ b/llvm/test/Analysis/ConstantFolding/freeze.ll
@@ -0,0 +1,30 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -constprop -S | FileCheck %s
+
+ at g = external global i16, align 1
+ at g2 = external global i16, align 1
+
+define i64 @ptr
diff 1() {
+; CHECK-LABEL: @ptr
diff 1(
+; 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
+}
+
+define i64 @ptr
diff 2() {
+; CHECK-LABEL: @ptr
diff 2(
+; CHECK-NEXT:    [[R:%.*]] = freeze i64 -2
+; CHECK-NEXT:    ret i64 [[R]]
+;
+  %i = ptrtoint i16* @g to i64
+  %gep = getelementptr i16, i16* @g, i64 1
+  %i2 = ptrtoint i16* %gep to i64
+  %
diff  = sub i64 %i, %i2
+  %r = freeze i64 %
diff 
+  ret i64 %r
+}


        


More information about the llvm-commits mailing list