This is an archive of the discontinued LLVM Phabricator instance.

[instcombine] propagate single use freeze(gep inbounds X)
ClosedPublic

Authored by reames on Oct 12 2021, 8:51 PM.

Details

Summary

This is a follow on for D111675 which implements the gep case. I'd originally left it out because I was hoping to actually implement the inrange todo, but after a bit of staring at the code, decided to leave it as is since it doesn't effect this use case (i.e. instcombine requires the op to freeze to be an instruction).

Diff Detail

Event Timeline

reames created this revision.Oct 12 2021, 8:51 PM
reames requested review of this revision.Oct 12 2021, 8:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2021, 8:51 PM
reames added inline comments.Oct 13 2021, 8:58 AM
llvm/lib/Analysis/ValueTracking.cpp
5059

For context here, inrange on a GEP operand is specified in a way which talks about UB triggered by uses. It doesn't explicitly state that poison is produced, but that appears to be the most consistent reading (we probably need to change LangRef).

inrange is only valid on constantexprs not instructions. However, this routine is written in terms of Operator, so in theory a constant expr could reach this point.

This issue exists in the previous code, I'm just adding the TODO since I reorganized it and was thinking about it.

nikic accepted this revision.Oct 13 2021, 9:07 AM

LG

llvm/lib/Analysis/ValueTracking.cpp
5059

Yeah, this should be checking for inrange. Do you plan to follow up with that?

This revision is now accepted and ready to land.Oct 13 2021, 9:07 AM
reames added inline comments.Oct 13 2021, 9:17 AM
llvm/lib/Analysis/ValueTracking.cpp
5059

If you're happy with a change without a test, sure. I haven't figured out how to exercise this yet.

I'm not signing up for the langref change though. :)

This revision was automatically updated to reflect the committed changes.