<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 3/8/2018 6:29 AM, Hiroshi 7 Inoue
via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:OF895085F3.6DCB329D-ON4925824A.002D0B90-4925824A.004FA3E6@notes.na.collabserv.com">
<p><font size="2">Hi,</font><br>
<br>
<font size="2">While comparing the code by LLVM and GCC for some
major libraries, I found that LLVM fails to apply jump
threading with a method whose return type is std::pair<int,
bool> (actually, any pair of 32-bit values like
std::pair<bool, int> and std::pair<int, int>).</font><br>
<font size="2">For example, jump threading does not work for the
if statement in func.</font><br>
<br>
<font size="2">std::pair<int, bool> callee(int v) {</font><br>
<font size="2"> int a = dummy(v);</font><br>
<font size="2"> if (a) return std::make_pair(dummy(v), true);</font><br>
<font size="2"> else return std::make_pair(v, v < 0);</font><br>
<font size="2">}</font><br>
<br>
<font size="2">int func(int v) {</font><br>
<font size="2"> std::pair<int, bool> rc = callee(v);</font><br>
<font size="2"> if (rc.second) {</font><br>
<font size="2"> // do something</font><br>
<font size="2"> }</font><br>
<font size="2"> ...</font><br>
<br>
<font size="2">SROA executed before the method inlining replaces
std::pair by i64 without splitting in both `callee` and `func`
since at this point no access to the individual fields is seen
to SROA.</font><br>
<font size="2">After inlining, jump threading fails to identify
that the incoming value is a constant due to additional
instructions (like or, and, trunc). </font><br>
<br>
<font size="2">I would appreciate it if I could have any
suggestions on how we can optimization such cases.</font><br>
<font size="2">I am planning to enhance InstCombine pass to
eliminate these additional instructions before jump threading
rather than enhancing SROA or jump threading.</font></p>
</blockquote>
<p>InstCombiner::SliceUpIllegalIntegerPHI already sort of does what
you want... but it's currently disabled for legal integer types.
Not sure what the performance implications would be if we run that
more aggressively.<br>
</p>
<p>-Eli<br>
</p>
<pre class="moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
</body>
</html>