@@ -218,7 +218,7 @@ class SelectOptimizeImpl {
218218private:
219219 // Select groups consist of consecutive select-like instructions with the same
220220 // condition. Between select-likes could be any number of auxiliary
221- // instructions related to the condition like not, sext/ zext, ashr/lshr
221+ // instructions related to the condition like not, zext
222222 struct SelectGroup {
223223 Value *Condition;
224224 SmallVector<SelectLike, 2 > Selects;
@@ -494,14 +494,7 @@ static Value *getTrueOrFalseValue(
494494
495495 auto *CBO = BO->clone ();
496496 auto CondIdx = SI.getConditionOpIndex ();
497- auto *AuxI = cast<Instruction>(CBO->getOperand (CondIdx));
498- if (isa<ZExtInst>(AuxI) || isa<LShrOperator>(AuxI)) {
499- CBO->setOperand (CondIdx, ConstantInt::get (CBO->getType (), 1 ));
500- } else {
501- assert ((isa<SExtInst>(AuxI) || isa<AShrOperator>(AuxI)) &&
502- " Non-supported type of operand" );
503- CBO->setOperand (CondIdx, ConstantInt::get (CBO->getType (), -1 ));
504- }
497+ CBO->setOperand (CondIdx, ConstantInt::get (CBO->getType (), 1 ));
505498
506499 unsigned OtherIdx = 1 - CondIdx;
507500 if (auto *IV = dyn_cast<Instruction>(CBO->getOperand (OtherIdx))) {
@@ -759,26 +752,18 @@ void SelectOptimizeImpl::collectSelectGroups(BasicBlock &BB,
759752 // Represents something that can be considered as select instruction.
760753 // Auxiliary instruction are instructions that depends on a condition and have
761754 // zero or some constant value on True/False branch, such as:
762- // * ZExt(1bit), SExt(1bit)
755+ // * ZExt(1bit)
763756 // * Not(1bit)
764- // * AShr(Xbit), X-1, LShr(XBit), X-1, where there is a condition like Xbit <=
765- // 0 somewhere above in BB
766757 struct SelectLikeInfo {
767758 Value *Cond;
768759 bool IsAuxiliary;
769760 bool IsInverted;
770761 unsigned ConditionIdx;
771762 };
772763
773- SmallPtrSet<Instruction *, 2 > SeenCmp;
774764 std::map<Value *, SelectLikeInfo> SelectInfo;
775765
776- auto ProcessSelectInfo = [&SeenCmp, &SelectInfo](Instruction *I) -> void {
777- if (auto *Cmp = dyn_cast<CmpInst>(I)) {
778- SeenCmp.insert (Cmp);
779- return ;
780- }
781-
766+ auto ProcessSelectInfo = [&SelectInfo](Instruction *I) -> void {
782767 Value *Cond;
783768 if (match (I, m_OneUse (m_ZExt (m_Value (Cond)))) &&
784769 Cond->getType ()->isIntegerTy (1 )) {
0 commit comments