[llvm] r267165 - [Hexagon] Teach mux expansion how to deal with undef predicates
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 09:47:01 PDT 2016
Author: kparzysz
Date: Fri Apr 22 11:47:01 2016
New Revision: 267165
URL: http://llvm.org/viewvc/llvm-project?rev=267165&view=rev
Log:
[Hexagon] Teach mux expansion how to deal with undef predicates
Added:
llvm/trunk/test/CodeGen/Hexagon/expand-condsets-pred-undef.ll
Modified:
llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp
Modified: llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp?rev=267165&r1=267164&r2=267165&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp Fri Apr 22 11:47:01 2016
@@ -110,6 +110,7 @@ namespace {
AU.addRequired<LiveIntervals>();
AU.addPreserved<LiveIntervals>();
AU.addPreserved<SlotIndexes>();
+ AU.addPreservedID(MachineDominatorsID);
MachineFunctionPass::getAnalysisUsage(AU);
}
virtual bool runOnMachineFunction(MachineFunction &MF);
@@ -166,7 +167,8 @@ namespace {
bool canMoveOver(MachineInstr *MI, ReferenceMap &Defs, ReferenceMap &Uses);
bool canMoveMemTo(MachineInstr *MI, MachineInstr *ToI, bool IsDown);
void predicateAt(RegisterRef RD, MachineInstr *MI,
- MachineBasicBlock::iterator Where, unsigned PredR, bool Cond);
+ MachineBasicBlock::iterator Where, unsigned PredR, bool Cond,
+ bool PredUndef);
void renameInRange(RegisterRef RO, RegisterRef RN, unsigned PredR,
bool Cond, MachineBasicBlock::iterator First,
MachineBasicBlock::iterator Last);
@@ -884,7 +886,8 @@ bool HexagonExpandCondsets::canMoveMemTo
/// Generate a predicated version of MI (where the condition is given via
/// PredR and Cond) at the point indicated by Where.
void HexagonExpandCondsets::predicateAt(RegisterRef RD, MachineInstr *MI,
- MachineBasicBlock::iterator Where, unsigned PredR, bool Cond) {
+ MachineBasicBlock::iterator Where, unsigned PredR, bool Cond,
+ bool PredUndef) {
// The problem with updating live intervals is that we can move one def
// past another def. In particular, this can happen when moving an A2_tfrt
// over an A2_tfrf defining the same register. From the point of view of
@@ -912,7 +915,7 @@ void HexagonExpandCondsets::predicateAt(
// Add the new def, then the predicate register, then the rest of the
// operands.
MB.addReg(RD.Reg, RegState::Define, RD.Sub);
- MB.addReg(PredR);
+ MB.addReg(PredR, PredUndef ? RegState::Undef : 0);
while (Ox < NP) {
MachineOperand &MO = MI->getOperand(Ox);
if (!MO.isReg() || !MO.isImplicit())
@@ -1070,9 +1073,9 @@ bool HexagonExpandCondsets::predicate(Ma
<< ", can move down: " << (CanDown ? "yes\n" : "no\n"));
MachineBasicBlock::iterator PastDefIt = std::next(DefIt);
if (CanUp)
- predicateAt(RD, DefI, PastDefIt, PredR, Cond);
+ predicateAt(RD, DefI, PastDefIt, PredR, Cond, MP.isUndef());
else if (CanDown)
- predicateAt(RD, DefI, TfrIt, PredR, Cond);
+ predicateAt(RD, DefI, TfrIt, PredR, Cond, MP.isUndef());
else
return false;
@@ -1308,6 +1311,7 @@ bool HexagonExpandCondsets::runOnMachine
TRI = MF.getSubtarget().getRegisterInfo();
LIS = &getAnalysis<LiveIntervals>();
MRI = &MF.getRegInfo();
+ DEBUG(MF.print(dbgs() << "Before expand-condsets\n", LIS->getSlotIndexes()));
bool Changed = false;
@@ -1330,6 +1334,10 @@ bool HexagonExpandCondsets::runOnMachine
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
postprocessUndefImplicitUses(*I);
+
+ if (Changed)
+ DEBUG(MF.print(dbgs() << "After expand-condsets\n", LIS->getSlotIndexes()));
+
return Changed;
}
Added: llvm/trunk/test/CodeGen/Hexagon/expand-condsets-pred-undef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Hexagon/expand-condsets-pred-undef.ll?rev=267165&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Hexagon/expand-condsets-pred-undef.ll (added)
+++ llvm/trunk/test/CodeGen/Hexagon/expand-condsets-pred-undef.ll Fri Apr 22 11:47:01 2016
@@ -0,0 +1,22 @@
+; RUN: llc -march=hexagon < %s
+; REQUIRES: asserts
+
+target triple = "hexagon"
+
+%struct.0 = type { i64, i16 }
+
+declare void @foo(%struct.0* noalias nocapture sret, i8 zeroext, i32, i64) #0
+
+define hidden fastcc void @fred(%struct.0* noalias nocapture %p, i8 zeroext %t, i32 %r) unnamed_addr #0 {
+entry:
+ %. = select i1 undef, i64 549755813888, i64 1024
+ %cmp104 = icmp ult i64 undef, %.
+ %inc = zext i1 %cmp104 to i32
+ %inc.r = add nsw i32 %inc, %r
+ %.inc.r = select i1 undef, i32 0, i32 %inc.r
+ tail call void @foo(%struct.0* sret %p, i8 zeroext %t, i32 %.inc.r, i64 undef)
+ ret void
+}
+
+attributes #0 = { noinline nounwind }
+
More information about the llvm-commits
mailing list