[llvm] 962c6fd - [JumpThreading] auto-generate complete test checks; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 8 05:26:38 PST 2021
Author: Sanjay Patel
Date: 2021-03-08T08:26:16-05:00
New Revision: 962c6fda4d33767dd84d8234f2ac086cd3e3b264
URL: https://github.com/llvm/llvm-project/commit/962c6fda4d33767dd84d8234f2ac086cd3e3b264
DIFF: https://github.com/llvm/llvm-project/commit/962c6fda4d33767dd84d8234f2ac086cd3e3b264.diff
LOG: [JumpThreading] auto-generate complete test checks; NFC
Added:
Modified:
llvm/test/Transforms/JumpThreading/thread-two-bbs.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/JumpThreading/thread-two-bbs.ll b/llvm/test/Transforms/JumpThreading/thread-two-bbs.ll
index 94832b6502ee..be4f6d7e0896 100644
--- a/llvm/test/Transforms/JumpThreading/thread-two-bbs.ll
+++ b/llvm/test/Transforms/JumpThreading/thread-two-bbs.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -jump-threading -S -verify | FileCheck %s
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
@@ -5,9 +6,34 @@ target triple = "x86_64-unknown-linux-gnu"
@a = global i32 0, align 4
+; Verify that we branch (twice) on cond2 without checking ptr.
+; Verify that we eliminate "bb.file".
+
define void @foo(i32 %cond1, i32 %cond2) {
-; CHECK-LABEL: @foo
-; CHECK-LABEL: entry
+; CHECK-LABEL: @foo(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[COND1:%.*]], 0
+; CHECK-NEXT: br i1 [[TOBOOL]], label [[BB_COND2_THREAD:%.*]], label [[BB_COND2:%.*]]
+; CHECK: bb.cond2:
+; CHECK-NEXT: call void @f1()
+; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[COND2:%.*]], 0
+; CHECK-NEXT: br i1 [[TOBOOL1]], label [[BB_F4:%.*]], label [[BB_F2:%.*]]
+; CHECK: bb.cond2.thread:
+; CHECK-NEXT: [[TOBOOL12:%.*]] = icmp eq i32 [[COND2]], 0
+; CHECK-NEXT: br i1 [[TOBOOL12]], label [[BB_F3:%.*]], label [[BB_F2]]
+; CHECK: bb.f2:
+; CHECK-NEXT: call void @f2()
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: bb.f3:
+; CHECK-NEXT: call void @f3()
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: bb.f4:
+; CHECK-NEXT: [[PTR3:%.*]] = phi i32* [ null, [[BB_COND2]] ]
+; CHECK-NEXT: call void @f4()
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
entry:
%tobool = icmp eq i32 %cond1, 0
br i1 %tobool, label %bb.cond2, label %bb.f1
@@ -15,25 +41,16 @@ entry:
bb.f1:
call void @f1()
br label %bb.cond2
-; Verify that we branch on cond2 without checking ptr.
-; CHECK: call void @f1()
-; CHECK-NEXT: icmp eq i32 %cond2, 0
-; CHECK-NEXT: label %bb.f4, label %bb.f2
bb.cond2:
%ptr = phi i32* [ null, %bb.f1 ], [ @a, %entry ]
%tobool1 = icmp eq i32 %cond2, 0
br i1 %tobool1, label %bb.file, label %bb.f2
-; Verify that we branch on cond2 without checking ptr.
-; CHECK: icmp eq i32 %cond2, 0
-; CHECK-NEXT: label %bb.f3, label %bb.f2
bb.f2:
call void @f2()
br label %exit
-; Verify that we eliminate this basic block.
-; CHECK-NOT: bb.file:
bb.file:
%cmp = icmp eq i32* %ptr, null
br i1 %cmp, label %bb.f4, label %bb.f3
@@ -51,17 +68,36 @@ exit:
}
declare void @f1()
-
declare void @f2()
-
declare void @f3()
-
declare void @f4()
+; Verify that we branch (twice) on cond2 without checking tobool again.
+; Verify that we eliminate "bb.cond1again".
+
define void @foo2(i32 %cond1, i32 %cond2) {
-; CHECK-LABEL: @foo2
-; CHECK-LABEL: entry
+; CHECK-LABEL: @foo2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[COND1:%.*]], 0
+; CHECK-NEXT: br i1 [[TOBOOL]], label [[BB_COND2:%.*]], label [[BB_COND2_THREAD:%.*]]
+; CHECK: bb.cond2:
+; CHECK-NEXT: call void @f1()
+; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[COND2:%.*]], 0
+; CHECK-NEXT: br i1 [[TOBOOL1]], label [[EXIT:%.*]], label [[BB_F3:%.*]]
+; CHECK: bb.cond2.thread:
+; CHECK-NEXT: call void @f2()
+; CHECK-NEXT: [[TOBOOL11:%.*]] = icmp eq i32 [[COND2]], 0
+; CHECK-NEXT: br i1 [[TOBOOL11]], label [[EXIT]], label [[BB_F4:%.*]]
+; CHECK: bb.f3:
+; CHECK-NEXT: call void @f3()
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: bb.f4:
+; CHECK-NEXT: call void @f4()
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret void
+;
entry:
%tobool = icmp ne i32 %cond1, 0
br i1 %tobool, label %bb.f1, label %bb.f2
@@ -69,25 +105,15 @@ entry:
bb.f1:
call void @f1()
br label %bb.cond2
-; Verify that we branch on cond2 without checking tobool again.
-; CHECK: call void @f1()
-; CHECK-NEXT: icmp eq i32 %cond2, 0
-; CHECK-NEXT: label %exit, label %bb.f3
bb.f2:
call void @f2()
br label %bb.cond2
-; Verify that we branch on cond2 without checking tobool again.
-; CHECK: call void @f2()
-; CHECK-NEXT: icmp eq i32 %cond2, 0
-; CHECK-NEXT: label %exit, label %bb.f4
bb.cond2:
%tobool1 = icmp eq i32 %cond2, 0
br i1 %tobool1, label %exit, label %bb.cond1again
-; Verify that we eliminate this basic block.
-; CHECK-NOT: bb.cond1again:
bb.cond1again:
br i1 %tobool, label %bb.f3, label %bb.f4
@@ -110,9 +136,30 @@ exit:
; icmp ugt i8* null, inttoptr (i64 4 to i8*)
;
; as "true", causing jump threading to a wrong destination.
+
define void @foo3(i8* %arg1, i8* %arg2) {
-; CHECK-LABEL: @foo
-; CHECK-NOT: bb_{{[^ ]*}}.thread:
+; CHECK-LABEL: @foo3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8* [[ARG1:%.*]], null
+; CHECK-NEXT: br i1 [[CMP1]], label [[BB_BAR1:%.*]], label [[BB_END:%.*]]
+; CHECK: bb_bar1:
+; CHECK-NEXT: call void @bar(i32 1)
+; CHECK-NEXT: br label [[BB_END]]
+; CHECK: bb_end:
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8* [[ARG2:%.*]], null
+; CHECK-NEXT: br i1 [[CMP2]], label [[BB_CONT:%.*]], label [[BB_BAR2:%.*]]
+; CHECK: bb_bar2:
+; CHECK-NEXT: call void @bar(i32 2)
+; CHECK-NEXT: br label [[BB_EXIT:%.*]]
+; CHECK: bb_cont:
+; CHECK-NEXT: [[CMP3:%.*]] = icmp ule i8* [[ARG1]], inttoptr (i64 4 to i8*)
+; CHECK-NEXT: br i1 [[CMP3]], label [[BB_EXIT]], label [[BB_BAR3:%.*]]
+; CHECK: bb_bar3:
+; CHECK-NEXT: call void @bar(i32 3)
+; CHECK-NEXT: br label [[BB_EXIT]]
+; CHECK: bb_exit:
+; CHECK-NEXT: ret void
+;
entry:
%cmp1 = icmp eq i8* %arg1, null
br i1 %cmp1, label %bb_bar1, label %bb_end
@@ -148,18 +195,28 @@ declare void @bar(i32)
;; successive basic blocks.
define i32 @foo4(i32* %0) {
-; CHECK-LABEL: @f
-; CHECK: br i1 %good, label %pred.bb, label %pred.pred.bb
+; CHECK-LABEL: @foo4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SIZE:%.*]] = call i64 @get_size(i32* [[TMP0:%.*]])
+; CHECK-NEXT: [[GOOD:%.*]] = icmp ugt i64 [[SIZE]], 3
+; CHECK-NEXT: br i1 [[GOOD]], label [[PRED_BB:%.*]], label [[PRED_PRED_BB:%.*]]
+; CHECK: pred.pred.bb:
+; CHECK-NEXT: call void @effect()
+; CHECK-NEXT: br label [[PRED_BB]]
+; CHECK: pred.bb:
+; CHECK-NEXT: [[V:%.*]] = load i32, i32* [[TMP0]], align 4
+; CHECK-NEXT: br label [[BB:%.*]]
+; CHECK: bb:
+; CHECK-NEXT: call void @effect1(i8* blockaddress(@foo4, [[BB]]))
+; CHECK-NEXT: br i1 [[GOOD]], label [[EXIT:%.*]], label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: ret i32 [[V]]
+;
entry:
%size = call i64 @get_size(i32* %0)
%good = icmp ugt i64 %size, 3
br i1 %good, label %pred.bb, label %pred.pred.bb
-; CHECK: pred.pred.bb:
-; CHECK: br label %pred.bb
-; CHECK: pred.bb:
-; CHECK: br label %bb
-; CHECK: bb:
pred.pred.bb: ; preds = %entry
call void @effect()
br label %pred.bb
More information about the llvm-commits
mailing list