Teach getGuaranteedNonPoisonOps() and thus programUndefinedIfPoison() that branching on poison is undefined behavior.
LangRef for br and switch:
If ‘cond’ is poison or undef, this instruction has undefined behavior.
If ‘value’ is poison or undef, this instruction has undefined behavior.
The primary effects of this change are:
- Strengthen transferal of nowrap flags from IR to SCEV (now works for non-latch branches)
- Strengthen isGuaranteedNotToBeUndefOrPoison, see e.g. the (Aggressive)InstCombine changes
- Strengthen noundef deduction in Attributor.
There is a comment below that says:
But the option actually used -unroll-max-upperbound=6. Previously SCEV didn't realize that the upperbound is actually 5, so this worked out fine. Now that it does, we have to use the correct value for the option.