Mesa (master): radeon/llvm: Add optimization for FP_ROUND
Tom Stellard
tstellar at kemper.freedesktop.org
Fri Sep 21 19:51:20 UTC 2012
Module: Mesa
Branch: master
Commit: aa8367dd13aa767b6af380d784380ed240dd9c8e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa8367dd13aa767b6af380d784380ed240dd9c8e
Author: Tom Stellard <thomas.stellard at amd.com>
Date: Thu Sep 13 15:08:40 2012 +0000
radeon/llvm: Add optimization for FP_ROUND
---
src/gallium/drivers/radeon/R600ISelLowering.cpp | 26 +++++++++++++++++++++++
src/gallium/drivers/radeon/R600ISelLowering.h | 1 +
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/gallium/drivers/radeon/R600ISelLowering.cpp b/src/gallium/drivers/radeon/R600ISelLowering.cpp
index a9b0c70..e84983d 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.cpp
+++ b/src/gallium/drivers/radeon/R600ISelLowering.cpp
@@ -50,6 +50,9 @@ R600TargetLowering::R600TargetLowering(TargetMachine &TM) :
setOperationAction(ISD::SETCC, MVT::i32, Custom);
setOperationAction(ISD::SETCC, MVT::f32, Custom);
setOperationAction(ISD::FP_TO_UINT, MVT::i1, Custom);
+
+ setTargetDAGCombine(ISD::FP_ROUND);
+
setSchedulingPreference(Sched::VLIW);
}
@@ -603,3 +606,26 @@ SDValue R600TargetLowering::LowerFormalArguments(
}
return Chain;
}
+
+//===----------------------------------------------------------------------===//
+// Custom DAG Optimizations
+//===----------------------------------------------------------------------===//
+
+SDValue R600TargetLowering::PerformDAGCombine(SDNode *N,
+ DAGCombinerInfo &DCI) const
+{
+ SelectionDAG &DAG = DCI.DAG;
+
+ switch (N->getOpcode()) {
+ // (f32 fp_round (f64 uint_to_fp a)) -> (f32 uint_to_fp a)
+ case ISD::FP_ROUND: {
+ SDValue Arg = N->getOperand(0);
+ if (Arg.getOpcode() == ISD::UINT_TO_FP && Arg.getValueType() == MVT::f64) {
+ return DAG.getNode(ISD::UINT_TO_FP, N->getDebugLoc(), N->getValueType(0),
+ Arg.getOperand(0));
+ }
+ break;
+ }
+ }
+ return SDValue();
+}
diff --git a/src/gallium/drivers/radeon/R600ISelLowering.h b/src/gallium/drivers/radeon/R600ISelLowering.h
index f2999a3..017c6db 100644
--- a/src/gallium/drivers/radeon/R600ISelLowering.h
+++ b/src/gallium/drivers/radeon/R600ISelLowering.h
@@ -27,6 +27,7 @@ public:
virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr *MI,
MachineBasicBlock * BB) const;
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
+ virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
void ReplaceNodeResults(SDNode * N,
SmallVectorImpl<SDValue> &Results,
SelectionDAG &DAG) const;
More information about the mesa-commit
mailing list