PrepareConstants step converts add/sub with 'negative' immediates to sub/add with a 'positive' imm to make promotion more simple. nuw already states that the add shouldn't cause an unsigned overflow, so it shouldn't need any tweaking. Plus, we also don't allow a sub with a 'negative' immediate to be safe underflow, so this functionality has been removed. The PrepareConstants step now just handles the add instructions that we've determined would be safe if they underflow.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/ARM/ARMCodeGenPrepare.cpp | ||
---|---|---|
480 ↗ | (On Diff #199999) | Perhaps you can be more specific here:
This is for unsigned values for which behaviour is well defined as wrapping or modulo behaviour. The Instructions that exhibit this behaviour are added to a list SafeUnderflow in function isSafeOverflow, which all looks a bit inconsistent (yep, I'm bikeshedding names ;-)). |
Comment Actions
Looks like a good improvement to me.
lib/Target/ARM/ARMCodeGenPrepare.cpp | ||
---|---|---|
305 ↗ | (On Diff #200241) | Looking at this example and comment again, we are explaining that this is not equivalent: %sub = sub i8 %a, 2 %cmp = icmp ule i8 %sub, 254 => %a32 = zext i8 %a to i32 %sub1 = sub i32 %a32, 2 %cmp = icmp ule i32 %sub1, 254 and alive agrees with us :-) and gives the same values: https://rise4fun.com/Alive/6gzR And changing the sub to a sub with constant 1 shows it is all good. |