[llvm] r278416 - [Hexagon] Allow non-returning calls in hardware loops
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 14:14:25 PDT 2016
Author: kparzysz
Date: Thu Aug 11 16:14:25 2016
New Revision: 278416
URL: http://llvm.org/viewvc/llvm-project?rev=278416&view=rev
Log:
[Hexagon] Allow non-returning calls in hardware loops
Added:
llvm/trunk/test/CodeGen/Hexagon/hwloop-noreturn-call.ll
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp
llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h
Modified: llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp?rev=278416&r1=278415&r2=278416&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonHardwareLoops.cpp Thu Aug 11 16:14:25 2016
@@ -962,8 +962,8 @@ bool HexagonHardwareLoops::isInvalidLoop
// Call is not allowed because the callee may use a hardware loop except for
// the case when the call never returns.
- if (MI->getDesc().isCall() && MI->getOpcode() != Hexagon::CALLv3nr)
- return true;
+ if (MI->getDesc().isCall())
+ return !TII->doesNotReturn(*MI);
// Check if the instruction defines a hardware loop register.
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp?rev=278416&r1=278415&r2=278416&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.cpp Thu Aug 11 16:14:25 2016
@@ -2972,6 +2972,12 @@ bool HexagonInstrInfo::canExecuteInBundl
}
+bool HexagonInstrInfo::doesNotReturn(const MachineInstr &CallMI) const {
+ unsigned Opc = CallMI.getOpcode();
+ return Opc == Hexagon::CALLv3nr || Opc == Hexagon::CALLRv3nr;
+}
+
+
bool HexagonInstrInfo::hasEHLabel(const MachineBasicBlock *B) const {
for (auto &I : *B)
if (I.isEHLabel())
Modified: llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h?rev=278416&r1=278415&r2=278416&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonInstrInfo.h Thu Aug 11 16:14:25 2016
@@ -360,6 +360,7 @@ public:
const MachineInstr &MI2) const;
bool canExecuteInBundle(const MachineInstr &First,
const MachineInstr &Second) const;
+ bool doesNotReturn(const MachineInstr &CallMI) const;
bool hasEHLabel(const MachineBasicBlock *B) const;
bool hasNonExtEquivalent(const MachineInstr &MI) const;
bool hasPseudoInstrPair(const MachineInstr &MI) const;
Added: llvm/trunk/test/CodeGen/Hexagon/hwloop-noreturn-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/hwloop-noreturn-call.ll?rev=278416&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/hwloop-noreturn-call.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/hwloop-noreturn-call.ll Thu Aug 11 16:14:25 2016
@@ -0,0 +1,63 @@
+; RUN: llc -march=hexagon < %s | FileCheck %s
+
+target triple = "hexagon"
+
+; CHECK-LABEL: danny:
+; CHECK-DAG: loop0
+; CHECK-DAG: call trap
+define void @danny(i32* %p, i32 %n, i32 %k) #0 {
+entry:
+ br label %for.body
+
+for.body: ; preds = %entry
+ %t0 = phi i32 [ 0, %entry ], [ %t1, %for.cont ]
+ %t1 = add i32 %t0, 1
+ %t2 = getelementptr i32, i32* %p, i32 %t0
+ store i32 %t1, i32* %t2, align 4
+ %c = icmp sgt i32 %t1, %k
+ br i1 %c, label %noret, label %for.cont
+
+for.cont:
+ %cmp = icmp slt i32 %t0, %n
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end: ; preds = %for.cond
+ ret void
+
+noret:
+ call void @trap() #1
+ br label %for.cont
+}
+
+; CHECK-LABEL: sammy:
+; CHECK-DAG: loop0
+; CHECK-DAG: callr
+define void @sammy(i32* %p, i32 %n, i32 %k, void (...)* %f) #0 {
+entry:
+ br label %for.body
+
+for.body: ; preds = %entry
+ %t0 = phi i32 [ 0, %entry ], [ %t1, %for.cont ]
+ %t1 = add i32 %t0, 1
+ %t2 = getelementptr i32, i32* %p, i32 %t0
+ store i32 %t1, i32* %t2, align 4
+ %c = icmp sgt i32 %t1, %k
+ br i1 %c, label %noret, label %for.cont
+
+for.cont:
+ %cmp = icmp slt i32 %t0, %n
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end: ; preds = %for.cond
+ ret void
+
+noret:
+ call void (...) %f() #1
+ br label %for.cont
+}
+
+declare void @trap() #1
+
+attributes #0 = { nounwind "target-cpu"="hexagonv60" "target-features"="+hvx,-hvx-double" }
+attributes #1 = { nounwind noreturn }
+
More information about the llvm-commits
mailing list