[llvm] r372943 - [IfConversion] Disallow TBB == FBB for valid triangles
Mikael Holmen via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 23:35:55 PDT 2019
Author: uabelho
Date: Wed Sep 25 23:35:55 2019
New Revision: 372943
URL: http://llvm.org/viewvc/llvm-project?rev=372943&view=rev
Log:
[IfConversion] Disallow TBB == FBB for valid triangles
Summary:
Previously the case
EBB
| \_
| |
| TBB
| /
FBB
was treated as a valid triangle also when TBB and FBB was the same basic
block. This could then lead to an invalid CFG when we removed the edge
from EBB to TBB, since that meant we would also remove the edge from EBB
to FBB.
Since TBB == FBB is quite a degenerated case of a triangle, we now
don't treat it as a valid triangle anymore, and thus we will avoid the
trouble with updating the CFG.
Reviewers: efriedma, dmgreen, kparzysz
Reviewed By: efriedma
Subscribers: bjope, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67832
Added:
llvm/trunk/test/CodeGen/ARM/ifcvt_triangleSameCvtNext.mir
Modified:
llvm/trunk/lib/CodeGen/IfConversion.cpp
Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=372943&r1=372942&r2=372943&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Wed Sep 25 23:35:55 2019
@@ -569,6 +569,9 @@ bool IfConverter::ValidTriangle(BBInfo &
bool FalseBranch, unsigned &Dups,
BranchProbability Prediction) const {
Dups = 0;
+ if (TrueBBI.BB == FalseBBI.BB)
+ return false;
+
if (TrueBBI.IsBeingAnalyzed || TrueBBI.IsDone)
return false;
Added: llvm/trunk/test/CodeGen/ARM/ifcvt_triangleSameCvtNext.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ifcvt_triangleSameCvtNext.mir?rev=372943&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/ifcvt_triangleSameCvtNext.mir (added)
+++ llvm/trunk/test/CodeGen/ARM/ifcvt_triangleSameCvtNext.mir Wed Sep 25 23:35:55 2019
@@ -0,0 +1,29 @@
+# RUN: llc -mtriple=arm-apple-ios -run-pass=if-converter -verify-machineinstrs %s -o - | FileCheck %s
+...
+---
+name: foo
+body: |
+ bb.0:
+ Bcc %bb.2, 1, $cpsr
+
+ bb.1:
+ $sp = tADDspi $sp, 2, 14, _
+ B %bb.1
+
+ bb.2:
+ Bcc %bb.3, 0, $cpsr
+ B %bb.2
+
+ bb.3:
+ Bcc %bb.1, 1, $cpsr
+ B %bb.1
+...
+
+# Both branches in bb.3 jump to bb.1. IfConversion shouldn't treat this as a
+# tringle and insert the tADDspi in bb3, but leave it as it is.
+
+# CHECK: bb.3:
+# CHECK: successors: %bb.1
+# CHECK-NOT: tADDspi
+# CHECK: Bcc %bb.1, 1, $cpsr
+# CHECK: B %bb.1
More information about the llvm-commits
mailing list