I think this is OK, but there might be cases where this break I'm currently missing.
In general, it should be able to avoid some spurious overdefined values, which is good.
Details
Details
- Reviewers
eli.friedman
Diff Detail
Diff Detail
Event Timeline
Comment Actions
The transformation valid... but I don't think it makes sense to perform it here. SCCP doesn't add any power to the transformation over instsimplify.
Comment Actions
I was worried about that. We already do some similar transformations in visitBinaryOp()
if (I.getOpcode() == Instruction::And) { // X and 0 = 0 if (NonOverdefVal->getConstant()->isNullValue()) return markConstant(IV, &I, NonOverdefVal->getConstant()); } else { if (ConstantInt *CI = NonOverdefVal->getConstantInt()) if (CI->isAllOnesValue()) // X or -1 = -1 return markConstant(IV, &I, NonOverdefVal->getConstant()); }
maybe we should get rid of these?
Comment Actions
There, SCCP actually does add power to the transformation; consider a construct like the following:
int f(); int g() { int x = 0; for (int i = 0; i < 1000000; ++i) { x &= f(); } return x; }
SCCP can prove that this function returns zero.