[PATCH] D104623: [X86] Update MachineLoopInfo in CMOV conversion.
Wang Tianqing via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 20 19:54:18 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbec4a8157d67: [X86] Update MachineLoopInfo in CMOV conversion. (authored by tianqing).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104623/new/
https://reviews.llvm.org/D104623
Files:
llvm/lib/Target/X86/X86CmovConversion.cpp
llvm/test/CodeGen/X86/x86-cmov-converter.ll
Index: llvm/test/CodeGen/X86/x86-cmov-converter.ll
===================================================================
--- llvm/test/CodeGen/X86/x86-cmov-converter.ll
+++ llvm/test/CodeGen/X86/x86-cmov-converter.ll
@@ -513,7 +513,12 @@
; CHECK-NEXT: movl %edi, (%rcx)
; CHECK-NEXT: addq $8, %rcx
; CHECK-NEXT: cmpq %rdx, %rcx
-; CHECK-NEXT: cmovbeq %rax, %rcx
+; CHECK-NEXT: ja .LBB13_5
+; CHECK-NEXT: # %bb.4: # %loop.body
+; CHECK-NEXT: # in Loop: Header=BB13_1 Depth=1
+; CHECK-NEXT: movq %rax, %rcx
+; CHECK-NEXT: .LBB13_5: # %loop.body
+; CHECK-NEXT: # in Loop: Header=BB13_1 Depth=1
; CHECK-NEXT: movl %edi, (%rcx)
; CHECK-NEXT: addl $1, %esi
; CHECK-NEXT: cmpl $1024, %esi # imm = 0x400
@@ -534,7 +539,7 @@
%cond = icmp slt i32 %iv.next, 1024
br i1 %cond, label %loop.body, label %exit
-; CHECK-NEXT: # %bb.4: # %exit
+; CHECK-NEXT: # %bb.6: # %exit
; CHECK-NEXT: retq
exit:
ret void
Index: llvm/lib/Target/X86/X86CmovConversion.cpp
===================================================================
--- llvm/lib/Target/X86/X86CmovConversion.cpp
+++ llvm/lib/Target/X86/X86CmovConversion.cpp
@@ -115,6 +115,7 @@
MachineRegisterInfo *MRI = nullptr;
const TargetInstrInfo *TII = nullptr;
const TargetRegisterInfo *TRI = nullptr;
+ MachineLoopInfo *MLI = nullptr;
TargetSchedModel TSchedModel;
/// List of consecutive CMOV instructions.
@@ -165,7 +166,7 @@
<< "**********\n");
bool Changed = false;
- MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
+ MLI = &getAnalysis<MachineLoopInfo>();
const TargetSubtargetInfo &STI = MF.getSubtarget();
MRI = &MF.getRegInfo();
TII = STI.getInstrInfo();
@@ -221,7 +222,7 @@
//===--------------------------------------------------------------------===//
// Build up the loops in pre-order.
- SmallVector<MachineLoop *, 4> Loops(MLI.begin(), MLI.end());
+ SmallVector<MachineLoop *, 4> Loops(MLI->begin(), MLI->end());
// Note that we need to check size on each iteration as we accumulate child
// loops.
for (int i = 0; i < (int)Loops.size(); ++i)
@@ -848,6 +849,12 @@
// Now remove the CMOV(s).
MBB->erase(MIItBegin, MIItEnd);
+
+ // Add new basic blocks to MachineLoopInfo.
+ if (MachineLoop *L = MLI->getLoopFor(MBB)) {
+ L->addBasicBlockToLoop(FalseMBB, MLI->getBase());
+ L->addBasicBlockToLoop(SinkMBB, MLI->getBase());
+ }
}
INITIALIZE_PASS_BEGIN(X86CmovConverterPass, DEBUG_TYPE, "X86 cmov Conversion",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104623.360348.patch
Type: text/x-patch
Size: 2514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210721/8bcf2527/attachment.bin>
More information about the llvm-commits
mailing list