This is the first part of fixing bug 24848 https://llvm.org/bugs/show_bug.cgi?id=24848.
When range metadata is provided, it should be used to constant fold comparisons with constant values.
Differential D12988
[Bug 24848] Use range metadata to constant fold comparisons with constant values • chenli on Sep 18 2015, 3:44 PM. Authored by
Details This is the first part of fixing bug 24848 https://llvm.org/bugs/show_bug.cgi?id=24848. When range metadata is provided, it should be used to constant fold comparisons with constant values.
Diff Detail Event Timeline
Comment Actions I think this looks ready to go in. @hfinkel WDYT?
Comment Actions LGTM too. There is obviously more than can be done here (where we propagate ranges through expressions), but that likely belongs in LVI. |
I'm still not very happy with the interface here -- I'd rather have this function do *just* the metadata parsing; and have the dyn_cast<Instruction>(..) logic in its caller. I'd also rename this GetConstantRangeFromMetadata (and not repeat "Range" in the CR bit and RangeMetadata):
and in its caller