Commit b0935390 by Nicolas Capens Committed by Nicolas Capens

Optimize x86 vector shift by constant.

BUG=swiftshader:15 Change-Id: I4b7b97f3de18c201a502d0bc38a2c845a1caf278 Reviewed-on: https://chromium-review.googlesource.com/392627Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarJim Stichnoth <stichnot@chromium.org>
parent 71c69373
...@@ -2142,9 +2142,27 @@ void TargetX86Base<TraitsType>::lowerArithmetic(const InstArithmetic *Instr) { ...@@ -2142,9 +2142,27 @@ void TargetX86Base<TraitsType>::lowerArithmetic(const InstArithmetic *Instr) {
llvm::report_fatal_error("Invalid vector multiply type"); llvm::report_fatal_error("Invalid vector multiply type");
} }
} break; } break;
case InstArithmetic::Shl: case InstArithmetic::Shl: {
case InstArithmetic::Lshr: assert(llvm::isa<Constant>(Src1) && "Non-constant shift not scalarized");
case InstArithmetic::Ashr: Variable *T = makeReg(Ty);
_movp(T, Src0);
_psll(T, Src1);
_movp(Dest, T);
} break;
case InstArithmetic::Lshr: {
assert(llvm::isa<Constant>(Src1) && "Non-constant shift not scalarized");
Variable *T = makeReg(Ty);
_movp(T, Src0);
_psrl(T, Src1);
_movp(Dest, T);
} break;
case InstArithmetic::Ashr: {
assert(llvm::isa<Constant>(Src1) && "Non-constant shift not scalarized");
Variable *T = makeReg(Ty);
_movp(T, Src0);
_psra(T, Src1);
_movp(Dest, T);
} break;
case InstArithmetic::Udiv: case InstArithmetic::Udiv:
case InstArithmetic::Urem: case InstArithmetic::Urem:
case InstArithmetic::Sdiv: case InstArithmetic::Sdiv:
...@@ -7009,6 +7027,9 @@ void TargetX86Base<TraitsType>::genTargetHelperCallFor(Inst *Instr) { ...@@ -7009,6 +7027,9 @@ void TargetX86Base<TraitsType>::genTargetHelperCallFor(Inst *Instr) {
case InstArithmetic::Shl: case InstArithmetic::Shl:
case InstArithmetic::Lshr: case InstArithmetic::Lshr:
case InstArithmetic::Ashr: case InstArithmetic::Ashr:
if (llvm::isa<Constant>(Src1)) {
return;
}
case InstArithmetic::Udiv: case InstArithmetic::Udiv:
case InstArithmetic::Urem: case InstArithmetic::Urem:
case InstArithmetic::Sdiv: case InstArithmetic::Sdiv:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment