From bdf25477f6f24621ceba2fb0a8ff1e7c0e181144 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 18 May 2022 12:03:15 +0200 Subject: [PATCH] [JumpThreading] Add additional freeze tests (NFC) These are for the getPredicateAt() codepath. --- llvm/test/Transforms/JumpThreading/freeze.ll | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/llvm/test/Transforms/JumpThreading/freeze.ll b/llvm/test/Transforms/JumpThreading/freeze.ll index 650cbeb..5df03c1 100644 --- a/llvm/test/Transforms/JumpThreading/freeze.ll +++ b/llvm/test/Transforms/JumpThreading/freeze.ll @@ -189,3 +189,65 @@ T2: F2: ret i32 %B } + +define i32 @freeze_known_predicate(i1 %cond) { +; CHECK-LABEL: @freeze_known_predicate( +; CHECK-NEXT: entry: +; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF:%.*]], label [[ELSE2:%.*]] +; CHECK: if: +; CHECK-NEXT: br label [[ELSE2]] +; CHECK: else2: +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 1, [[IF]] ], [ 2, [[ENTRY:%.*]] ] +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[PHI]], 0 +; CHECK-NEXT: ret i32 1 +; +entry: + br i1 %cond, label %if, label %join + +if: + br label %join + +join: + %phi = phi i32 [ 1, %if ], [ 2, %entry ] + %cmp = icmp eq i32 %phi, 0 + %cmp.fr = freeze i1 %cmp + br i1 %cmp.fr, label %if2, label %else2 + +if2: + ret i32 0 + +else2: + ret i32 1 +} + +define i32 @freeze_known_predicate_barrier(i1 %cond) { +; CHECK-LABEL: @freeze_known_predicate_barrier( +; CHECK-NEXT: entry: +; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF:%.*]], label [[ELSE2:%.*]] +; CHECK: if: +; CHECK-NEXT: br label [[ELSE2]] +; CHECK: else2: +; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 1, [[IF]] ], [ 2, [[ENTRY:%.*]] ] +; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[PHI]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = call i32 @f1() +; CHECK-NEXT: ret i32 1 +; +entry: + br i1 %cond, label %if, label %join + +if: + br label %join + +join: + %phi = phi i32 [ 1, %if ], [ 2, %entry ] + %cmp = icmp eq i32 %phi, 0 + %cmp.fr = freeze i1 %cmp + call i32 @f1() + br i1 %cmp.fr, label %if2, label %else2 + +if2: + ret i32 0 + +else2: + ret i32 1 +} -- 2.7.4