}
bool
-GV100LegalizeSSA::handleSHL(Instruction *i)
+GV100LegalizeSSA::handleShift(Instruction *i)
{
- if (i->src(0).getFile() != FILE_GPR) {
- bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1),
- i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_L |
- NV50_IR_SUBOP_SHF_HI;
+ Value *zero = bld.mkImm(0);
+ Value *src1 = i->getSrc(1);
+ Value *src0, *src2;
+ uint8_t subOp = i->op == OP_SHL ? NV50_IR_SUBOP_SHF_L : NV50_IR_SUBOP_SHF_R;
+
+ if (i->op == OP_SHL && i->src(0).getFile() == FILE_GPR) {
+ src0 = i->getSrc(0);
+ src2 = zero;
} else {
- bld.mkOp3(OP_SHF, i->dType, i->getDef(0), i->getSrc(0), i->getSrc(1),
- bld.mkImm(0))->subOp = NV50_IR_SUBOP_SHF_L;
+ src0 = zero;
+ src2 = i->getSrc(0);
+ subOp |= NV50_IR_SUBOP_SHF_HI;
}
- return true;
-}
+ if (i->subOp & NV50_IR_SUBOP_SHIFT_WRAP)
+ subOp |= NV50_IR_SUBOP_SHF_W;
-bool
-GV100LegalizeSSA::handleSHR(Instruction *i)
-{
- bld.mkOp3(OP_SHF, i->dType, i->getDef(0), bld.mkImm(0), i->getSrc(1),
- i->getSrc(0))->subOp = NV50_IR_SUBOP_SHF_R | NV50_IR_SUBOP_SHF_HI;
+ bld.mkOp3(OP_SHF, i->dType, i->getDef(0), src0, src1, src2)->subOp = subOp;
return true;
}
lowered = handleNOT(i);
break;
case OP_SHL:
- lowered = handleSHL(i);
- break;
case OP_SHR:
- lowered = handleSHR(i);
+ lowered = handleShift(i);
break;
case OP_SET:
case OP_SET_AND:
bool handleQUADPOP(Instruction *);
bool handleSET(Instruction *);
bool handleSHFL(Instruction *);
- bool handleSHL(Instruction *);
- bool handleSHR(Instruction *);
+ bool handleShift(Instruction *);
bool handleSUB(Instruction *);
};
}