Chromium Code Reviews| Index: src/IceTargetLoweringX8632.cpp |
| diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
| index 3808ecbb85cabb7ed570f2c82a6d8cabf93d07a6..371e38931077032b86ea8086e1c4c5136cd11e57 100644 |
| --- a/src/IceTargetLoweringX8632.cpp |
| +++ b/src/IceTargetLoweringX8632.cpp |
| @@ -3292,42 +3292,75 @@ void TargetX8632::lowerRet(const InstRet *Inst) { |
| } |
| void TargetX8632::lowerSelect(const InstSelect *Inst) { |
| - // a=d?b:c ==> cmp d,0; a=b; jne L1; FakeUse(a); a=c; L1: |
| Variable *Dest = Inst->getDest(); |
| Operand *SrcT = Inst->getTrueOperand(); |
| Operand *SrcF = Inst->getFalseOperand(); |
| - Operand *Condition = legalize(Inst->getCondition()); |
| - Constant *Zero = Ctx->getConstantZero(IceType_i32); |
| - InstX8632Label *Label = InstX8632Label::create(Func, this); |
| - |
| - if (Dest->getType() == IceType_i64) { |
| - Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); |
| - Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); |
| - Operand *SrcLoRI = legalize(loOperand(SrcT), Legal_Reg | Legal_Imm, true); |
| - Operand *SrcHiRI = legalize(hiOperand(SrcT), Legal_Reg | Legal_Imm, true); |
| - _cmp(Condition, Zero); |
| - _mov(DestLo, SrcLoRI); |
| - _mov(DestHi, SrcHiRI); |
| - _br(InstX8632Br::Br_ne, Label); |
| - Context.insert(InstFakeUse::create(Func, DestLo)); |
| - Context.insert(InstFakeUse::create(Func, DestHi)); |
| - Operand *SrcFLo = loOperand(SrcF); |
| - Operand *SrcFHi = hiOperand(SrcF); |
| - SrcLoRI = legalize(SrcFLo, Legal_Reg | Legal_Imm, true); |
| - SrcHiRI = legalize(SrcFHi, Legal_Reg | Legal_Imm, true); |
| - _mov(DestLo, SrcLoRI); |
| - _mov(DestHi, SrcHiRI); |
| + Operand *Condition = Inst->getCondition(); |
| + |
| + if (isVectorType(Dest->getType())) { |
| + // a=d?b:c ==> d=sext(d); a=(b&d)|(c&~d) |
| + // TODO(wala): SSE4.1 has blendvps and pblendvb. SSE4.1 also has |
| + // blendps and pblendw for constant condition operands. |
| + Type SrcTy = SrcT->getType(); |
| + Variable *T = makeReg(SrcTy); |
| + Variable *T2 = makeReg(SrcTy); |
| + // Sign extend the condition operand if applicable. |
| + if (SrcTy == IceType_v4f32) { |
| + // The sext operation takes only integer arguments. |
| + Variable *T3 = Func->makeVariable(IceType_v4i32, Context.getNode()); |
| + lowerCast(InstCast::create(Func, InstCast::Sext, T3, Condition)); |
| + _movp(T, T3); |
| + } else if (typeElementType(SrcTy) != IceType_i1) { |
| + lowerCast(InstCast::create(Func, InstCast::Sext, T, Condition)); |
| + } else { |
| + _movp(T, Condition); |
| + } |
| + // ALIGNHACK: Until stack alignment support is implemented, the |
| + // bitwise vector instructions need to have both operands in |
| + // registers. Once there is support for stack alignment, LEGAL_HACK |
| + // can be removed. |
| +#define LEGAL_HACK(Vect) legalizeToVar((Vect)) |
| + _movp(T2, T); |
| + _pand(T, LEGAL_HACK(SrcT)); |
| + _pandn(T2, LEGAL_HACK(SrcF)); |
| + _por(T, T2); |
| + _movp(Dest, T); |
| +#undef LEGAL_HACK |
| } else { |
|
Jim Stichnoth
2014/07/23 20:06:37
I'd echo Jan's comment from the other CL - add a r
wala
2014/07/23 20:49:54
Done.
|
| - _cmp(Condition, Zero); |
| - SrcT = legalize(SrcT, Legal_Reg | Legal_Imm, true); |
| - _mov(Dest, SrcT); |
| - _br(InstX8632Br::Br_ne, Label); |
| - Context.insert(InstFakeUse::create(Func, Dest)); |
| - SrcF = legalize(SrcF, Legal_Reg | Legal_Imm, true); |
| - _mov(Dest, SrcF); |
| - } |
| + // a=d?b:c ==> cmp d,0; a=b; jne L1; FakeUse(a); a=c; L1: |
| + Operand *ConditionRMI = legalize(Condition); |
| + Constant *Zero = Ctx->getConstantZero(IceType_i32); |
| + InstX8632Label *Label = InstX8632Label::create(Func, this); |
| - Context.insert(Label); |
| + if (Dest->getType() == IceType_i64) { |
| + Variable *DestLo = llvm::cast<Variable>(loOperand(Dest)); |
| + Variable *DestHi = llvm::cast<Variable>(hiOperand(Dest)); |
| + Operand *SrcLoRI = legalize(loOperand(SrcT), Legal_Reg | Legal_Imm, true); |
| + Operand *SrcHiRI = legalize(hiOperand(SrcT), Legal_Reg | Legal_Imm, true); |
| + _cmp(ConditionRMI, Zero); |
| + _mov(DestLo, SrcLoRI); |
| + _mov(DestHi, SrcHiRI); |
| + _br(InstX8632Br::Br_ne, Label); |
| + Context.insert(InstFakeUse::create(Func, DestLo)); |
| + Context.insert(InstFakeUse::create(Func, DestHi)); |
| + Operand *SrcFLo = loOperand(SrcF); |
| + Operand *SrcFHi = hiOperand(SrcF); |
| + SrcLoRI = legalize(SrcFLo, Legal_Reg | Legal_Imm, true); |
| + SrcHiRI = legalize(SrcFHi, Legal_Reg | Legal_Imm, true); |
| + _mov(DestLo, SrcLoRI); |
| + _mov(DestHi, SrcHiRI); |
| + } else { |
| + _cmp(ConditionRMI, Zero); |
| + SrcT = legalize(SrcT, Legal_Reg | Legal_Imm, true); |
| + _mov(Dest, SrcT); |
| + _br(InstX8632Br::Br_ne, Label); |
| + Context.insert(InstFakeUse::create(Func, Dest)); |
| + SrcF = legalize(SrcF, Legal_Reg | Legal_Imm, true); |
| + _mov(Dest, SrcF); |
| + } |
| + |
| + Context.insert(Label); |
| + } |
| } |
| void TargetX8632::lowerStore(const InstStore *Inst) { |