[llvm] bc6d7ed - [InstSimplify] Add test for PR49839 (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 08:32:33 PDT 2022


Author: Nikita Popov
Date: 2022-04-12T17:32:25+02:00
New Revision: bc6d7ed8a9b9501d5d977a0825629791ee802fd6

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

LOG: [InstSimplify] Add test for PR49839 (NFC)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/phi.ll b/llvm/test/Transforms/InstSimplify/phi.ll
index f1cdd8b960cbb..5d2ef05c7d319 100644
--- a/llvm/test/Transforms/InstSimplify/phi.ll
+++ b/llvm/test/Transforms/InstSimplify/phi.ll
@@ -152,3 +152,45 @@ EXIT:
   %r = phi i8 [poison, %A], [poison, %B]
   ret i8 %r
 }
+
+ at g = extern_weak global i32
+
+define i64 @pr49839_with_poison(i1 %c) {
+; CHECK-LABEL: @pr49839_with_poison(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[IF:%.*]], label [[JOIN:%.*]]
+; CHECK:       if:
+; CHECK-NEXT:    br label [[JOIN]]
+; CHECK:       join:
+; CHECK-NEXT:    ret i64 srem (i64 1, i64 ptrtoint (i32* @g to i64))
+;
+entry:
+  br i1 %c, label %if, label %join
+
+if:
+  br label %join
+
+join:
+  %phi = phi i64 [ poison, %if ], [ srem (i64 1, i64 ptrtoint (i32* @g to i64)) , %entry ]
+  ret i64 %phi
+}
+
+define i64 @pr49839_without_poison(i1 %c) {
+; CHECK-LABEL: @pr49839_without_poison(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[IF:%.*]], label [[JOIN:%.*]]
+; CHECK:       if:
+; CHECK-NEXT:    br label [[JOIN]]
+; CHECK:       join:
+; CHECK-NEXT:    ret i64 srem (i64 1, i64 ptrtoint (i32* @g to i64))
+;
+entry:
+  br i1 %c, label %if, label %join
+
+if:
+  br label %join
+
+join:
+  %phi = phi i64 [ srem (i64 1, i64 ptrtoint (i32* @g to i64)), %if ], [ srem (i64 1, i64 ptrtoint (i32* @g to i64)) , %entry ]
+  ret i64 %phi
+}


        


More information about the llvm-commits mailing list