[llvm] 85fb9cc - Precommit a test file for D84941
Juneyoung Lee via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 18:51:27 PDT 2022
Author: Juneyoung Lee
Date: 2022-05-18T10:41:25+09:00
New Revision: 85fb9ccfa387f78eb77bdfdfd5f0d18d43bcebeb
URL: https://github.com/llvm/llvm-project/commit/85fb9ccfa387f78eb77bdfdfd5f0d18d43bcebeb
DIFF: https://github.com/llvm/llvm-project/commit/85fb9ccfa387f78eb77bdfdfd5f0d18d43bcebeb.diff
LOG: Precommit a test file for D84941
Added:
llvm/test/Transforms/JumpThreading/freeze-impliescond.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/JumpThreading/freeze-impliescond.ll b/llvm/test/Transforms/JumpThreading/freeze-impliescond.ll
new file mode 100644
index 000000000000..470782dab7c1
--- /dev/null
+++ b/llvm/test/Transforms/JumpThreading/freeze-impliescond.ll
@@ -0,0 +1,182 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -jump-threading -S < %s | FileCheck %s
+
+declare void @f()
+
+define void @test1(i1 %cond, i1 %dummycond) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
+; CHECK: A:
+; CHECK-NEXT: br i1 [[DUMMYCOND:%.*]], label [[REACHABLE:%.*]], label [[DUMMY:%.*]]
+; CHECK: B:
+; CHECK-NEXT: br i1 [[DUMMYCOND]], label [[REACHABLE]], label [[DUMMY]]
+; CHECK: REACHABLE:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret void
+; CHECK: DUMMY:
+; CHECK-NEXT: ret void
+;
+ br i1 %cond, label %A, label %B
+A:
+ br i1 %dummycond, label %A2, label %DUMMY
+A2:
+ %cond.fr = freeze i1 %cond
+ br i1 %cond.fr, label %REACHABLE, label %UNREACHABLE
+B:
+ br i1 %dummycond, label %B2, label %DUMMY
+B2:
+ %cond.fr2 = freeze i1 %cond
+ br i1 %cond.fr2, label %UNREACHABLE, label %REACHABLE
+
+REACHABLE:
+ call void @f()
+ ret void
+UNREACHABLE:
+ ret void
+DUMMY:
+ ret void
+}
+
+define void @test2(i1 %cond, i1 %dummycond) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: [[COND_FR0:%.*]] = freeze i1 [[COND:%.*]]
+; CHECK-NEXT: br i1 [[COND_FR0]], label [[A:%.*]], label [[B:%.*]]
+; CHECK: A:
+; CHECK-NEXT: br i1 [[DUMMYCOND:%.*]], label [[A2:%.*]], label [[DUMMY:%.*]]
+; CHECK: A2:
+; CHECK-NEXT: [[COND_FR:%.*]] = freeze i1 [[COND]]
+; CHECK-NEXT: br i1 [[COND_FR]], label [[REACHABLE:%.*]], label [[UNREACHABLE:%.*]]
+; CHECK: B:
+; CHECK-NEXT: br i1 [[DUMMYCOND]], label [[B2:%.*]], label [[DUMMY]]
+; CHECK: B2:
+; CHECK-NEXT: [[COND_FR2:%.*]] = freeze i1 [[COND]]
+; CHECK-NEXT: br i1 [[COND_FR2]], label [[UNREACHABLE]], label [[REACHABLE]]
+; CHECK: REACHABLE:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret void
+; CHECK: UNREACHABLE:
+; CHECK-NEXT: ret void
+; CHECK: DUMMY:
+; CHECK-NEXT: ret void
+;
+ %cond.fr0 = freeze i1 %cond
+ br i1 %cond.fr0, label %A, label %B
+A:
+ br i1 %dummycond, label %A2, label %DUMMY
+A2:
+ %cond.fr = freeze i1 %cond
+ br i1 %cond.fr, label %REACHABLE, label %UNREACHABLE
+B:
+ br i1 %dummycond, label %B2, label %DUMMY
+B2:
+ %cond.fr2 = freeze i1 %cond
+ br i1 %cond.fr2, label %UNREACHABLE, label %REACHABLE
+
+REACHABLE:
+ call void @f()
+ ret void
+UNREACHABLE:
+ ret void
+DUMMY:
+ ret void
+}
+
+define void @and_noopt(i32 %x, i1 %cond2, i1 %dummycond) {
+; CHECK-LABEL: @and_noopt(
+; CHECK-NEXT: [[COND1:%.*]] = icmp slt i32 0, [[X:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[COND1]], [[COND2:%.*]]
+; CHECK-NEXT: [[COND_FR0:%.*]] = freeze i1 [[COND]]
+; CHECK-NEXT: br i1 [[COND_FR0]], label [[A:%.*]], label [[B:%.*]]
+; CHECK: A:
+; CHECK-NEXT: br i1 [[DUMMYCOND:%.*]], label [[A2:%.*]], label [[DUMMY:%.*]]
+; CHECK: A2:
+; CHECK-NEXT: [[COND_FR:%.*]] = freeze i1 [[COND1]]
+; CHECK-NEXT: br i1 [[COND_FR]], label [[REACHABLE:%.*]], label [[UNREACHABLE:%.*]]
+; CHECK: B:
+; CHECK-NEXT: br i1 [[DUMMYCOND]], label [[B2:%.*]], label [[DUMMY]]
+; CHECK: B2:
+; CHECK-NEXT: [[COND_FR2:%.*]] = freeze i1 [[COND1]]
+; CHECK-NEXT: br i1 [[COND_FR2]], label [[UNREACHABLE]], label [[REACHABLE]]
+; CHECK: REACHABLE:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret void
+; CHECK: UNREACHABLE:
+; CHECK-NEXT: ret void
+; CHECK: DUMMY:
+; CHECK-NEXT: ret void
+;
+ %cond1 = icmp slt i32 0, %x
+ %cond = and i1 %cond1, %cond2
+ %cond.fr0 = freeze i1 %cond
+ br i1 %cond.fr0, label %A, label %B
+A:
+ br i1 %dummycond, label %A2, label %DUMMY
+A2:
+ %cond.fr = freeze i1 %cond1
+ br i1 %cond.fr, label %REACHABLE, label %UNREACHABLE
+B:
+ br i1 %dummycond, label %B2, label %DUMMY
+B2:
+ %cond.fr2 = freeze i1 %cond1
+ br i1 %cond.fr2, label %UNREACHABLE, label %REACHABLE
+
+REACHABLE:
+ call void @f()
+ ret void
+UNREACHABLE:
+ ret void
+DUMMY:
+ ret void
+}
+
+define void @and(i32 %x, i1 %cond2, i1 %dummycond) {
+; CHECK-LABEL: @and(
+; CHECK-NEXT: [[COND1:%.*]] = icmp slt i32 0, [[X:%.*]]
+; CHECK-NEXT: [[COND:%.*]] = and i1 [[COND1]], [[COND2:%.*]]
+; CHECK-NEXT: br i1 [[COND]], label [[A:%.*]], label [[B:%.*]]
+; CHECK: A:
+; CHECK-NEXT: br i1 [[DUMMYCOND:%.*]], label [[A2:%.*]], label [[DUMMY:%.*]]
+; CHECK: A2:
+; CHECK-NEXT: [[COND_FR:%.*]] = freeze i1 [[COND1]]
+; CHECK-NEXT: br i1 [[COND_FR]], label [[REACHABLE:%.*]], label [[UNREACHABLE:%.*]]
+; CHECK: B:
+; CHECK-NEXT: br i1 [[DUMMYCOND]], label [[B2:%.*]], label [[DUMMY]]
+; CHECK: B2:
+; CHECK-NEXT: [[COND_FR2:%.*]] = freeze i1 [[COND1]]
+; CHECK-NEXT: br i1 [[COND_FR2]], label [[REACHABLE]], label [[REACHABLE2:%.*]]
+; CHECK: REACHABLE:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret void
+; CHECK: REACHABLE2:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret void
+; CHECK: UNREACHABLE:
+; CHECK-NEXT: ret void
+; CHECK: DUMMY:
+; CHECK-NEXT: ret void
+;
+ %cond1 = icmp slt i32 0, %x
+ %cond = and i1 %cond1, %cond2
+ br i1 %cond, label %A, label %B
+A:
+ br i1 %dummycond, label %A2, label %DUMMY
+A2:
+ %cond.fr = freeze i1 %cond1
+ br i1 %cond.fr, label %REACHABLE, label %UNREACHABLE
+B:
+ br i1 %dummycond, label %B2, label %DUMMY
+B2:
+ %cond.fr2 = freeze i1 %cond1
+ br i1 %cond.fr2, label %REACHABLE, label %REACHABLE2
+
+REACHABLE:
+ call void @f()
+ ret void
+REACHABLE2:
+ call void @f()
+ ret void
+UNREACHABLE:
+ ret void
+DUMMY:
+ ret void
+}
More information about the llvm-commits
mailing list