This is an archive of the discontinued LLVM Phabricator instance.

[ConstraintElim] Support add nsw with negative constants.
Needs ReviewPublic

Authored by fhahn on Nov 21 2022, 4:03 AM.

Details

Summary

add nsw with negative constants can be used for reasoning, if the
first operand is larger or equal to the subtracted constant. Then the
value won't cross 0.

Add a precondition to ensure that.

Diff Detail

Event Timeline

fhahn created this revision.Nov 21 2022, 4:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 4:03 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
fhahn requested review of this revision.Nov 21 2022, 4:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2022, 4:03 AM
nikic added a comment.Dec 5 2022, 6:25 AM

Looks like gep-arithmetic-add.ll fails in pre-commit CI.

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
371

Is this correct if C is INT_MIN?