return C1;
return Constant::getAllOnesValue(C1->getType()); // undef | X -> ~0
case Instruction::LShr:
- if (isa<UndefValue>(C2) && isa<UndefValue>(C1))
- return C1; // undef lshr undef -> undef
- return Constant::getNullValue(C1->getType()); // X lshr undef -> 0
- // undef lshr X -> 0
+ // X >>l undef -> undef
+ if (isa<UndefValue>(C2))
+ return C2;
+ // undef >>l X -> 0
+ return Constant::getNullValue(C1->getType());
case Instruction::AShr:
- if (!isa<UndefValue>(C2)) // undef ashr X --> all ones
- return Constant::getAllOnesValue(C1->getType());
- else if (isa<UndefValue>(C1))
- return C1; // undef ashr undef -> undef
- else
- return C1; // X ashr undef --> X
+ // X >>a undef -> undef
+ if (isa<UndefValue>(C2))
+ return C2;
+ // undef >>a X -> all ones
+ return Constant::getAllOnesValue(C1->getType());
case Instruction::Shl:
- if (isa<UndefValue>(C2) && isa<UndefValue>(C1))
- return C1; // undef shl undef -> undef
- // undef << X -> 0 or X << undef -> 0
+ // X << undef -> undef
+ if (isa<UndefValue>(C2))
+ return C2;
+ // undef << X -> 0
return Constant::getNullValue(C1->getType());
}
}