Let some of the pointer bithacking fold away if we know the LSB are 0.
Diff Detail
- Build Status
Buildable 188428
Event Timeline
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
727 | Should this also go under if? Looks like for an overaligned case it is a no-op. I can actually see shl by 0 in the produced IR. |
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
727 | Yes, but this was less effort than writing separate code to handle the mask shifting |
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
709–715 | Shouldn't this folding get handled by the IR folder already? Why do we need to special case it here? |
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
709–715 | I don't follow. This check switches the path to avoid creating the ptrtoint |
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
709–715 | What I meant is that when the alignment of Addr is high enough, this could theoretically be optimized away automatically, based on the known-bits computation of Addr causing PtrLSB to be folded to 0, and then AddrInt ending up with no uses. However, that was a silly comment on my part: InstSimplifyFolder couldn't remove an instruction with no uses, even if it could optimize away everything else. So the ptrtoint would remain regardless. And, this pass comes late enough in the pass pipeline that we aren't going to clean that up after the fact, so we really do want a special-case like this. OK. | |
725 | You lost the isLittleEndian case here. I think the best fix would be to minimize the amount of code in the conditional section. Instead of setting PMV.ShiftAmt here, just set PtrLSB = ConstantInt::getNullValue(IntTy) in the else clause, and move the entire PMV.ShiftAmt computation into unconditional code -- letting the constant folder take care of things. |
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
733 | JFTR: same comment as previous patch that added this code: don't need the if. |
llvm/lib/CodeGen/AtomicExpandPass.cpp | ||
---|---|---|
733 | I was thinking this was a handy marker to remove unnecessary code whenever typed pointers are finally dropped |
Shouldn't this folding get handled by the IR folder already? Why do we need to special case it here?