[Beignet] [PATCH] GBE: Only emit multiply when immediate is not one.

Ruiling Song ruiling.song at intel.com
Tue Mar 10 23:39:24 PDT 2015


As constant propagation will introduce constantExpr and gep instruction,
I choose not to run constant propagation pass after RemoveGep pass.
So, here only generate Multiply as needed.
We may do such kind of optimization in Gen IR level in the future.

This could fix the performance regression introduced by:
"GBE: Import constantexpr lower pass from pNaCl"
to the opencv case:
opencv_perf_imgproc/OCL_BilateralFixture_Bilateral

Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
 backend/src/llvm/llvm_passes.cpp |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
index 1b40389..223f61b 100644
--- a/backend/src/llvm/llvm_passes.cpp
+++ b/backend/src/llvm/llvm_passes.cpp
@@ -346,9 +346,11 @@ namespace gbe
           }
         }
 
-        BinaryOperator* tmpMul = 
-          BinaryOperator::Create(Instruction::Mul, newConstSize, operand,
-              "", GEPInst);
+        Value* tmpMul = operand;
+        if (size != 1) {
+          tmpMul = BinaryOperator::Create(Instruction::Mul, newConstSize, operand,
+                                         "", GEPInst);
+        }
         currentAddrInst = 
           BinaryOperator::Create(Instruction::Add, currentAddrInst, tmpMul,
               "", GEPInst);
-- 
1.7.10.4



More information about the Beignet mailing list