[llvm] f561713 - [JumpThreading] Add a test for D84944 ; NFC
Juneyoung Lee via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 23:21:22 PDT 2020
Author: Juneyoung Lee
Date: 2020-07-31T15:20:59+09:00
New Revision: f561713d7513110b6e791959734cca9e0bf7fe33
URL: https://github.com/llvm/llvm-project/commit/f561713d7513110b6e791959734cca9e0bf7fe33
DIFF: https://github.com/llvm/llvm-project/commit/f561713d7513110b6e791959734cca9e0bf7fe33.diff
LOG: [JumpThreading] Add a test for D84944 ; NFC
Added:
llvm/test/Transforms/JumpThreading/pre-load.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/JumpThreading/pre-load.ll b/llvm/test/Transforms/JumpThreading/pre-load.ll
new file mode 100644
index 000000000000..0a8af988477f
--- /dev/null
+++ b/llvm/test/Transforms/JumpThreading/pre-load.ll
@@ -0,0 +1,84 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -jump-threading -S < %s | FileCheck %s
+
+ at x = global i32 0
+ at y = global i32 0
+
+declare void @f()
+declare void @g()
+
+define i32 @pre(i1 %cond, i32 %n) {
+; CHECK-LABEL: @pre(
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[C_THREAD:%.*]], label [[C:%.*]]
+; CHECK: C.thread:
+; CHECK-NEXT: store i32 0, i32* @x, align 4
+; CHECK-NEXT: br label [[YES:%.*]]
+; CHECK: C:
+; CHECK-NEXT: [[A_PR:%.*]] = load i32, i32* @y, align 4
+; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[A_PR]], 0
+; CHECK-NEXT: br i1 [[COND2]], label [[YES]], label [[NO:%.*]]
+; CHECK: YES:
+; CHECK-NEXT: [[A4:%.*]] = phi i32 [ 0, [[C_THREAD]] ], [ [[A_PR]], [[C]] ]
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret i32 [[A4]]
+; CHECK: NO:
+; CHECK-NEXT: call void @g()
+; CHECK-NEXT: ret i32 1
+;
+ br i1 %cond, label %A, label %B
+A:
+ store i32 0, i32* @x
+ br label %C
+B:
+ br label %C
+C:
+ %ptr = phi i32* [@x, %A], [@y, %B]
+ %a = load i32, i32* %ptr
+ %cond2 = icmp eq i32 %a, 0
+ br i1 %cond2, label %YES, label %NO
+YES:
+ call void @f()
+ ret i32 %a
+NO:
+ call void @g()
+ ret i32 1
+}
+
+define i32 @pre_freeze(i1 %cond, i32 %n) {
+; CHECK-LABEL: @pre_freeze(
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[C:%.*]]
+; CHECK: A:
+; CHECK-NEXT: store i32 0, i32* @x, align 4
+; CHECK-NEXT: br label [[C]]
+; CHECK: C:
+; CHECK-NEXT: [[PTR:%.*]] = phi i32* [ @x, [[A]] ], [ @y, [[TMP0:%.*]] ]
+; CHECK-NEXT: [[A:%.*]] = load i32, i32* [[PTR]], align 4
+; CHECK-NEXT: [[COND2:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT: [[COND2_FR:%.*]] = freeze i1 [[COND2]]
+; CHECK-NEXT: br i1 [[COND2_FR]], label [[YES:%.*]], label [[NO:%.*]]
+; CHECK: YES:
+; CHECK-NEXT: call void @f()
+; CHECK-NEXT: ret i32 [[A]]
+; CHECK: NO:
+; CHECK-NEXT: call void @g()
+; CHECK-NEXT: ret i32 1
+;
+ br i1 %cond, label %A, label %B
+A:
+ store i32 0, i32* @x
+ br label %C
+B:
+ br label %C
+C:
+ %ptr = phi i32* [@x, %A], [@y, %B]
+ %a = load i32, i32* %ptr
+ %cond2 = icmp eq i32 %a, 0
+ %cond2.fr = freeze i1 %cond2
+ br i1 %cond2.fr, label %YES, label %NO
+YES:
+ call void @f()
+ ret i32 %a
+NO:
+ call void @g()
+ ret i32 1
+}
More information about the llvm-commits
mailing list