[llvm] 2a7e1a1 - [InstSimplify] Precommit tests for dominate conditions are not single predecessor; NFC
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 15 01:12:52 PDT 2023
Author: chenglin.bi
Date: 2023-04-15T16:12:31+08:00
New Revision: 2a7e1a132dff95ffe76ecb5cd8dea8d1f95e1046
URL: https://github.com/llvm/llvm-project/commit/2a7e1a132dff95ffe76ecb5cd8dea8d1f95e1046
DIFF: https://github.com/llvm/llvm-project/commit/2a7e1a132dff95ffe76ecb5cd8dea8d1f95e1046.diff
LOG: [InstSimplify] Precommit tests for dominate conditions are not single predecessor; NFC
Added:
Modified:
llvm/test/Transforms/InstSimplify/domcondition.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/domcondition.ll b/llvm/test/Transforms/InstSimplify/domcondition.ll
index b6508c329e3c4..43be5de6bf95d 100644
--- a/llvm/test/Transforms/InstSimplify/domcondition.ll
+++ b/llvm/test/Transforms/InstSimplify/domcondition.ll
@@ -216,3 +216,65 @@ cond.end:
%cond = phi i32 [ %xor, %cond.true ], [ 0, %entry ]
ret i32 %cond
}
+
+define i32 @xor_simplify_by_dci(i32 %x, i32 %y, i1 %c) {
+; CHECK-LABEL: @xor_simplify_by_dci(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_END:%.*]]
+; CHECK: cond.true:
+; CHECK-NEXT: br i1 [[C:%.*]], label [[XORBB:%.*]], label [[COND_END]]
+; CHECK: xorbb:
+; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X]], [[Y]]
+; CHECK-NEXT: br label [[COND_END]]
+; CHECK: cond.end:
+; CHECK-NEXT: [[COND:%.*]] = phi i32 [ [[XOR]], [[XORBB]] ], [ 0, [[ENTRY:%.*]] ], [ 0, [[COND_TRUE]] ]
+; CHECK-NEXT: ret i32 [[COND]]
+;
+entry:
+ %cmp = icmp eq i32 %x, %y
+ br i1 %cmp, label %cond.true, label %cond.end
+
+cond.true:
+ br i1 %c, label %xorbb, label %cond.end
+
+xorbb:
+ %xor = xor i32 %x, %y
+ br label %cond.end
+
+cond.end:
+ %cond = phi i32 [ %xor, %xorbb ], [ 0, %entry ], [0, %cond.true]
+ ret i32 %cond
+}
+
+define void @icmp_simplify_by_dci(i32 %a, i32 %b, i1 %x) {
+; CHECK-LABEL: @icmp_simplify_by_dci(
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: br i1 [[CMP1]], label [[END:%.*]], label [[TAKEN:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: br i1 [[X:%.*]], label [[SELBB:%.*]], label [[END]]
+; CHECK: selbb:
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[A]], [[B]]
+; CHECK-NEXT: [[C:%.*]] = select i1 [[CMP2]], i32 20, i32 0
+; CHECK-NEXT: call void @foo(i32 [[C]])
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: ret void
+;
+ %cmp1 = icmp eq i32 %a, %b
+ br i1 %cmp1, label %end, label %taken
+
+taken:
+ br i1 %x, label %selbb, label %end
+
+selbb:
+ %cmp2 = icmp ne i32 %a, %b
+ %c = select i1 %cmp2, i32 20, i32 0
+ call void @foo(i32 %c)
+ br label %end
+
+end:
+ ret void
+}
+
+declare void @foo(i32)
More information about the llvm-commits
mailing list