@@ -218,7 +218,7 @@ class SelectOptimizeImpl {
218
218
private:
219
219
// Select groups consist of consecutive select-like instructions with the same
220
220
// 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
222
222
struct SelectGroup {
223
223
Value *Condition;
224
224
SmallVector<SelectLike, 2 > Selects;
@@ -494,14 +494,7 @@ static Value *getTrueOrFalseValue(
494
494
495
495
auto *CBO = BO->clone ();
496
496
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 ));
505
498
506
499
unsigned OtherIdx = 1 - CondIdx;
507
500
if (auto *IV = dyn_cast<Instruction>(CBO->getOperand (OtherIdx))) {
@@ -759,26 +752,18 @@ void SelectOptimizeImpl::collectSelectGroups(BasicBlock &BB,
759
752
// Represents something that can be considered as select instruction.
760
753
// Auxiliary instruction are instructions that depends on a condition and have
761
754
// zero or some constant value on True/False branch, such as:
762
- // * ZExt(1bit), SExt(1bit)
755
+ // * ZExt(1bit)
763
756
// * Not(1bit)
764
- // * AShr(Xbit), X-1, LShr(XBit), X-1, where there is a condition like Xbit <=
765
- // 0 somewhere above in BB
766
757
struct SelectLikeInfo {
767
758
Value *Cond;
768
759
bool IsAuxiliary;
769
760
bool IsInverted;
770
761
unsigned ConditionIdx;
771
762
};
772
763
773
- SmallPtrSet<Instruction *, 2 > SeenCmp;
774
764
std::map<Value *, SelectLikeInfo> SelectInfo;
775
765
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 {
782
767
Value *Cond;
783
768
if (match (I, m_OneUse (m_ZExt (m_Value (Cond)))) &&
784
769
Cond->getType ()->isIntegerTy (1 )) {
0 commit comments