summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-04-09 09:33:07 +0000
committerNate Begeman <natebegeman@mac.com>2005-04-09 09:33:07 +0000
commit2f6412231901bd725128cfe228b6603661b0af5e (patch)
tree6a2a9ce2e1f013b971c288e0a8f054249563255c /llvm/lib
parent7d3e44fb122eb6e707439e265b1103857307342c (diff)
downloadbcm5719-llvm-2f6412231901bd725128cfe228b6603661b0af5e.tar.gz
bcm5719-llvm-2f6412231901bd725128cfe228b6603661b0af5e.zip
Optimize FSEL a bit for fneg arguments. This fixes the recently added test
case so that we emit _test_fneg_sel: .LBB_test_fneg_sel_0: ; fsel f1, f1, f3, f2 blr instead of: _test_fneg_sel: .LBB_test_fneg_sel_0: ; fneg f0, f1 fneg f0, f0 fsel f1, f0, f3, f2 blr llvm-svn: 21177
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
index 7ad633a39d8..aabfed87596 100644
--- a/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
+++ b/llvm/lib/Target/PowerPC/PPC32ISelPattern.cpp
@@ -999,7 +999,6 @@ unsigned ISel::SelectExprFP(SDOperand N, unsigned Result)
SetCC->getCondition() != ISD::SETEQ &&
SetCC->getCondition() != ISD::SETNE) {
MVT::ValueType VT = SetCC->getOperand(0).getValueType();
- Tmp1 = SelectExpr(SetCC->getOperand(0)); // Val to compare against
unsigned TV = SelectExpr(N.getOperand(1)); // Use if TRUE
unsigned FV = SelectExpr(N.getOperand(2)); // Use if FALSE
@@ -1009,29 +1008,31 @@ unsigned ISel::SelectExprFP(SDOperand N, unsigned Result)
default: assert(0 && "Invalid FSEL condition"); abort();
case ISD::SETULT:
case ISD::SETLT:
- BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp1).addReg(FV).addReg(TV);
- return Result;
+ std::swap(TV, FV); // fsel is natively setge, swap operands for setlt
case ISD::SETUGE:
case ISD::SETGE:
+ Tmp1 = SelectExpr(SetCC->getOperand(0)); // Val to compare against
BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp1).addReg(TV).addReg(FV);
return Result;
case ISD::SETUGT:
- case ISD::SETGT: {
- Tmp2 = MakeReg(VT);
- BuildMI(BB, PPC::FNEG, 1, Tmp2).addReg(Tmp1);
- BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp2).addReg(FV).addReg(TV);
- return Result;
- }
+ case ISD::SETGT:
+ std::swap(TV, FV); // fsel is natively setge, swap operands for setlt
case ISD::SETULE:
case ISD::SETLE: {
- Tmp2 = MakeReg(VT);
- BuildMI(BB, PPC::FNEG, 1, Tmp2).addReg(Tmp1);
+ if (SetCC->getOperand(0).getOpcode() == ISD::FNEG) {
+ Tmp2 = SelectExpr(SetCC->getOperand(0).getOperand(0));
+ } else {
+ Tmp2 = MakeReg(VT);
+ Tmp1 = SelectExpr(SetCC->getOperand(0)); // Val to compare against
+ BuildMI(BB, PPC::FNEG, 1, Tmp2).addReg(Tmp1);
+ }
BuildMI(BB, PPC::FSEL, 3, Result).addReg(Tmp2).addReg(TV).addReg(FV);
return Result;
}
}
} else {
Opc = (MVT::f64 == VT) ? PPC::FSUB : PPC::FSUBS;
+ Tmp1 = SelectExpr(SetCC->getOperand(0)); // Val to compare against
Tmp2 = SelectExpr(SetCC->getOperand(1));
Tmp3 = MakeReg(VT);
switch(SetCC->getCondition()) {
OpenPOWER on IntegriCloud