diff options
author | Chris Lattner <sabre@nondot.org> | 2011-02-10 05:23:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-02-10 05:23:05 +0000 |
commit | 98457101fc21f519134d877259a17bf36894bdfe (patch) | |
tree | e2b2177579bc486c7b35d5af41a2b08bca6facf9 /llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | |
parent | dcef03fba222eae47c0658712a8a168e18ae5002 (diff) | |
download | bcm5719-llvm-98457101fc21f519134d877259a17bf36894bdfe.tar.gz bcm5719-llvm-98457101fc21f519134d877259a17bf36894bdfe.zip |
Enhance the "compare with shift" and "compare with div"
optimizations to be much more aggressive in the face of
exact/nsw/nuw div and shifts. For example, these (which
are the same except the first is 'exact' sdiv:
define i1 @sdiv_icmp4_exact(i64 %X) nounwind {
%A = sdiv exact i64 %X, -5 ; X/-5 == 0 --> x == 0
%B = icmp eq i64 %A, 0
ret i1 %B
}
define i1 @sdiv_icmp4(i64 %X) nounwind {
%A = sdiv i64 %X, -5 ; X/-5 == 0 --> x == 0
%B = icmp eq i64 %A, 0
ret i1 %B
}
compile down to:
define i1 @sdiv_icmp4_exact(i64 %X) nounwind {
%1 = icmp eq i64 %X, 0
ret i1 %1
}
define i1 @sdiv_icmp4(i64 %X) nounwind {
%X.off = add i64 %X, 4
%1 = icmp ult i64 %X.off, 9
ret i1 %1
}
This happens when you do something like:
(ptr1-ptr2) == 42
where the pointers are pointers to non-unit types.
llvm-svn: 125266
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
0 files changed, 0 insertions, 0 deletions