[LLVMdev] Conditonal to constant promotion?

matthieu at illinois.edu matthieu at illinois.edu
Fri Aug 22 13:10:39 PDT 2008


Hi,

I tried the memory dependency analysis posted by
Wojciech on the attached test case. The analysis 
had to fallback to conservatives answers sometimes,
probably (but not sure) due to the existence of several 
select instructions that might prevent the analysis 
from correctly find the answer.

In this specific test case, these selects are provably 
useless and I am trying to get rid of them either by finding
the correct transformation pass or writing/extending an existing
one.

The instructions I am referring to are in the basic block
bb.nph15.split:


bb.nph15.split:         ; preds = %bb.nph15
        %umax26 = select i1 %0, i32 1, i32 %m           ; <i32> [#uses=2]
        %umax22 = select i1 %15, i32 1, i32 %o          ; <i32> [#uses=2]
        %umax = select i1 %16, i32 1, i32 %n            ; <i32> [#uses=1]
        br i1 %16, label %bb.nph15.split.bb5.preheader.us_crit_edge, label %bb.nph15.split.bb5.preheader_crit_edge

This block has only one predecessor:

bb.nph15:               ; preds = %entry
        icmp eq i32 %o, 0               ; <i1>:15 [#uses=2]
        icmp eq i32 %n, 0               ; <i1>:16 [#uses=2]
        br i1 %15, label %bb.nph15.return_crit_edge, label %bb.nph15.split


For instance, %umax22 is provably equal to %o,
as the conditional used by select (%15)  is the same 
as the one used by the conditional branch that brought
us there.

I tried sccp, condprop and constprop and none of them seems
to handle this case. Is there one?

Matthieu Delahaye
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase.ll
Type: application/octet-stream
Size: 5272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080822/7f53ea90/attachment.obj>


More information about the llvm-dev mailing list