[llvm-commits] [PATCH] FindPHIForConditionForwarding - switch's case ranges support.
Stepan Dyatkovskiy
stpworld at narod.ru
Tue Jul 10 10:49:17 PDT 2012
Hi all. How do you find the extension of FindPHIForConditionForwarding
for switches with case-ranges.
In current implementation it is supposed that 'switch' contains single
numbers only.
Consider the code below:
switch i32 %m, label %sw.bb4 [
i32 0, label %sw.bb0
i32 1, label %sw.bb1
]
sw.bb0:
br label %return
sw.bb1:
br label %return
return:
%retval = phi i32 [ 1, %sw.bb1 ], [ 0, %sw.bb0 ]
The %retval will simplified by this method to the next one:
%retval = phi i32 [ %m, %sw.bb1 ], [ %m, %sw.bb0 ]
Please review the patch attached, that allows to do something like this
for switch with case ranges:
Consider the code below (case ranges syntax is still "under construction"):
switch i32 %m, label %sw.bb4 [
[<i32 0, i32 5>], label %sw.bb0
[<i32 20, i32 25>], label %sw.bb1
]
sw.bb0:
br label %return
sw.bb1:
br label %return
return:
%retval = phi i32 [ 2, %sw.bb1 ], [ 22, %sw.bb0 ]
Since '2' belongs to [<i32 0, i32 5>] and '22' belongs to [<i32 20, i32
25>], the %retval will also simplified to the next one:
%retval = phi i32 [ %m, %sw.bb1 ], [ %m, %sw.bb0 ]
-Stepan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cr-forward-switch-phi.patch
Type: text/x-patch
Size: 2774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120710/2e204bc2/attachment.bin>
More information about the llvm-commits
mailing list