summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/R600/SIISelLowering.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2014-09-29 14:59:38 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2014-09-29 14:59:38 +0000
commit3d4233fe4851702142a32d89d0ac5746c9791592 (patch)
tree98bc53127976f94df63f1279b15cbb5736d11609 /llvm/lib/Target/R600/SIISelLowering.cpp
parent02cb0ff7db7ff9673eeedffce5918a90e6c8f570 (diff)
downloadbcm5719-llvm-3d4233fe4851702142a32d89d0ac5746c9791592.tar.gz
bcm5719-llvm-3d4233fe4851702142a32d89d0ac5746c9791592.zip
R600/SI: Also fix fsub + fadd a, a to mad combines
llvm-svn: 218609
Diffstat (limited to 'llvm/lib/Target/R600/SIISelLowering.cpp')
-rw-r--r--llvm/lib/Target/R600/SIISelLowering.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/Target/R600/SIISelLowering.cpp b/llvm/lib/Target/R600/SIISelLowering.cpp
index 10e6c17f6cc..f042aaa70c0 100644
--- a/llvm/lib/Target/R600/SIISelLowering.cpp
+++ b/llvm/lib/Target/R600/SIISelLowering.cpp
@@ -1484,6 +1484,28 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
return DAG.getNode(AMDGPUISD::MAD, DL, VT, A, B, C);
}
+
+ if (LHS.getOpcode() == ISD::FADD) {
+ // (fsub (fadd a, a), c) -> mad 2.0, a, (fneg c)
+
+ SDValue A = LHS.getOperand(0);
+ if (A == LHS.getOperand(1)) {
+ const SDValue Two = DAG.getTargetConstantFP(2.0, MVT::f32);
+ SDValue NegRHS = DAG.getNode(ISD::FNEG, DL, VT, RHS);
+
+ return DAG.getNode(AMDGPUISD::MAD, DL, VT, Two, A, NegRHS);
+ }
+ }
+
+ if (RHS.getOpcode() == ISD::FADD) {
+ // (fsub c, (fadd a, a)) -> mad -2.0, a, c
+
+ SDValue A = RHS.getOperand(0);
+ if (A == RHS.getOperand(1)) {
+ const SDValue NegTwo = DAG.getTargetConstantFP(-2.0, MVT::f32);
+ return DAG.getNode(AMDGPUISD::MAD, DL, VT, NegTwo, A, LHS);
+ }
+ }
}
break;
OpenPOWER on IntegriCloud