[PATCH] D85343: [ConstraintElimination] Add support for Or.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 12:30:24 PDT 2020
fhahn created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
fhahn requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85343
Files:
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/or.ll
Index: llvm/test/Transforms/ConstraintElimination/or.ll
===================================================================
--- llvm/test/Transforms/ConstraintElimination/or.ll
+++ llvm/test/Transforms/ConstraintElimination/or.ll
@@ -18,15 +18,15 @@
; CHECK-NEXT: ret i32 10
; CHECK: exit:
; CHECK-NEXT: [[F_1:%.*]] = icmp ule i32 [[X]], [[Z]]
-; CHECK-NEXT: call void @use(i1 [[F_1]])
+; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_5:%.*]] = icmp ule i32 [[X]], [[A]]
; CHECK-NEXT: call void @use(i1 [[C_5]])
; CHECK-NEXT: [[T_1:%.*]] = icmp ugt i32 [[Y]], [[Z]]
-; CHECK-NEXT: call void @use(i1 [[T_1]])
+; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: [[T_2:%.*]] = icmp ugt i32 [[X]], [[Y]]
-; CHECK-NEXT: call void @use(i1 [[T_2]])
+; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: [[T_3:%.*]] = icmp ugt i32 [[X]], [[Z]]
-; CHECK-NEXT: call void @use(i1 [[T_3]])
+; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: ret i32 20
;
entry:
Index: llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -172,6 +172,18 @@
auto *Br = dyn_cast<BranchInst>(BB.getTerminator());
if (!Br || !Br->isConditional())
continue;
+
+ if (match(Br->getCondition(), m_Or(m_Cmp(), m_Cmp()))) {
+ if (Br->getSuccessor(1)->getSinglePredecessor()) {
+ auto *OrI = cast<Instruction>(Br->getCondition());
+ WorkList.emplace_back(DT.getNode(Br->getSuccessor(1)),
+ cast<CmpInst>(OrI->getOperand(0)), true);
+ WorkList.emplace_back(DT.getNode(Br->getSuccessor(1)),
+ cast<CmpInst>(OrI->getOperand(1)), true);
+ }
+ continue;
+ }
+
auto *CmpI = dyn_cast<CmpInst>(Br->getCondition());
if (!CmpI)
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85343.283342.patch
Type: text/x-patch
Size: 1982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200805/7778d822/attachment.bin>
More information about the llvm-commits
mailing list