This is an archive of the discontinued LLVM Phabricator instance.

[SCCP] Propagate undef when visiting some instructions
Needs ReviewPublic

Authored by StephenFan on Jun 12 2023, 9:42 PM.

Details

Reviewers
nikic
fhahn
Summary

If a value lattice is constantrange_including_undef, replaceSignInst to
unsigned Inst is invalid. But SCCPSolver didn't propagate undef when
visiting some instructions. This patch fixes this.

https://alive2.llvm.org/ce/z/85Ec-i
https://alive2.llvm.org/ce/z/jVZf67
https://alive2.llvm.org/ce/z/hZCw7k

Diff Detail

Event Timeline

StephenFan created this revision.Jun 12 2023, 9:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2023, 9:42 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
StephenFan requested review of this revision.Jun 12 2023, 9:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2023, 9:42 PM
nikic added a reviewer: fhahn.Jun 13 2023, 1:28 AM
nikic added inline comments.
llvm/lib/Transforms/Utils/SCCPSolver.cpp
1246

Hm, this seems a bit inaccurate, in that something like zext i32 undef to i64 will still produce a value where the top bits are all zero, not undef. This would be more precisely modeled by treating undef as a full-set input. But then we would no longer model the case where undef doesn't matter as accurately...

StephenFan added inline comments.Jun 13 2023, 1:43 AM
llvm/lib/Transforms/Utils/SCCPSolver.cpp
1246

Yes. The way sccp handles undef is very conservative. For this patch, not only zext i32 under to i64, but also and i32 undef, -1 will be regarded as including_undef.