[PATCH] [InstCombine] Teach how to fold a select into a cttz/ctlz with the 'is_zero_undef' flag cleared.
Andrea Di Biagio
Andrea_DiBiagio at sn.scee.net
Fri Jan 9 04:05:19 PST 2015
Hi hfinkel, majnemer, RKSimon,
Hi all,
This patch teaches the Instruction Combiner how to fold a cttz/ctlz followed by a icmp plus select into a single cttz/ctlz with flag 'is_zero_undef' cleared.
Example:
```
%a = tail call i32 @llvm.cttz.i32(i32 %x, i1 true)
%b = icmp ne i32 %x, 0
%c = select i1 %b, i32 %a, i32 32
```
In this example, the condition value used by the select instruction compares value %x for equality against zero.
Value %x is also used by the call to the llvm intrinsic cttz. So, the select instruction would propagate the sizeof in bits of %x (i.e. 32) if %x is zero.
The entire `cttz+icmp+select` sequence can be safely folded into:
```
%c = tail call i32 @llvm.cttz.i32(i32 %x, i1 false)
```
Added test InstCombine/select-cmp-cttz-ctlz.ll.
Please let me know if ok to submit.
Thanks,
Andrea
http://reviews.llvm.org/D6891
Files:
lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/intrinsics.ll
test/Transforms/InstCombine/select-cmp-cttz-ctlz.ll
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6891.17922.patch
Type: text/x-patch
Size: 13721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150109/c1d694ae/attachment.bin>
More information about the llvm-commits
mailing list