[llvm] r176103 - R600/SI: swap operands if it helps folding
Christian Konig
christian.koenig at amd.com
Tue Feb 26 09:52:36 PST 2013
Author: ckoenig
Date: Tue Feb 26 11:52:36 2013
New Revision: 176103
URL: http://llvm.org/viewvc/llvm-project?rev=176103&view=rev
Log:
R600/SI: swap operands if it helps folding
Signed-off-by: Christian König <christian.koenig at amd.com>
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
Modified:
llvm/trunk/lib/Target/R600/SIISelLowering.cpp
Modified: llvm/trunk/lib/Target/R600/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIISelLowering.cpp?rev=176103&r1=176102&r2=176103&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/R600/SIISelLowering.cpp Tue Feb 26 11:52:36 2013
@@ -545,8 +545,22 @@ SDNode *SITargetLowering::PostISelFoldin
// Is this a VSrc or SSrc operand ?
unsigned RegClass = Desc->OpInfo[Op].RegClass;
- if (!isVSrc(RegClass) && !isSSrc(RegClass))
+ if (!isVSrc(RegClass) && !isSSrc(RegClass)) {
+
+ if (i == 1 && Desc->isCommutable() &&
+ fitsRegClass(DAG, Ops[0], RegClass) &&
+ foldImm(Ops[1], Immediate, ScalarSlotUsed)) {
+
+ assert(isVSrc(Desc->OpInfo[NumDefs].RegClass) ||
+ isSSrc(Desc->OpInfo[NumDefs].RegClass));
+
+ // Swap commutable operands
+ SDValue Tmp = Ops[1];
+ Ops[1] = Ops[0];
+ Ops[0] = Tmp;
+ }
continue;
+ }
// Try to fold the immediates
if (!foldImm(Ops[i], Immediate, ScalarSlotUsed)) {
More information about the llvm-commits
mailing list