This is an archive of the discontinued LLVM Phabricator instance.

[LVI] Handle conditions in the form of (cond1 && cond2)
ClosedPublic

Authored by apilipenko on Aug 5 2016, 4:59 AM.

Details

Summary

Teach LVI how to gather information from conditions in the form of (cond1 && cond2). Our out-of-tree front-end emits range checks in this form.

Diff Detail

Repository
rL LLVM

Event Timeline

apilipenko updated this revision to Diff 66928.Aug 5 2016, 4:59 AM
apilipenko retitled this revision from to [LVI] Handle conditions in the form of (cond1 && cond2).
apilipenko updated this object.
apilipenko added a reviewer: reames.
apilipenko added a subscriber: llvm-commits.
sanjoy accepted this revision.Aug 9 2016, 2:57 PM
sanjoy edited edge metadata.

lgtm with comments addressed

lib/Analysis/LazyValueInfo.cpp
1244 ↗(On Diff #66928)

I'd suggest using a visited set here. That way you don't infinitely recurse in unreachable code (I'm not sure if that is filtered out already) and won't have exponential time complexity for cases like

%c0 = icmp ..
%c1 = icmp ..
%a0 = and %c0, %c1
%a1 = and %a0, %a0
%a2 = and %a1, %a1
%a3 = and %a2, %a2
%a4 = and %a3, %a3
%a5 = and %a4, %a4
...
test/Transforms/CorrelatedValuePropagation/add.ll
155 ↗(On Diff #66928)

I'd also throw in a

if (a s< Unknown && Unknown2)
  b = a + 1;

to

if (a s< Unknown && Unknown2)
  b = a nsw+ 1;

type transform.

This revision is now accepted and ready to land.Aug 9 2016, 2:57 PM
This revision was automatically updated to reflect the committed changes.