<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - EarlyCSE does not benefit from "and" conditions"
href="https://bugs.llvm.org/show_bug.cgi?id=37635">37635</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>EarlyCSE does not benefit from "and" conditions
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>max.kazantsev@azul.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Given 2 tests:
define i32 @test_01(i32 %a, i32 %b) {
entry:
%cond = icmp slt i32 %a, %b
br i1 %cond, label %if.true, label %if.false
if.true:
%cond2 = icmp slt i32 %a, %b
%x = select i1 %cond2, i32 %a, i32 %b
ret i32 %x
if.false:
%cond3 = icmp slt i32 %a, %b
%y = select i1 %cond3, i32 %a, i32 %b
ret i32 %y
}
define i32 @test_02(i32 %a, i32 %b, i1 %c) {
entry:
%cond = icmp slt i32 %a, %b
%and.cond = and i1 %cond, %c
br i1 %and.cond, label %if.true, label %if.false
if.true:
%cond2 = icmp slt i32 %a, %b
%x = select i1 %cond2, i32 %a, i32 %b
ret i32 %x
if.false:
%cond3 = icmp slt i32 %a, %b
%y = select i1 %cond3, i32 %a, i32 %b
ret i32 %y
}
EarlyCSE is able to eliminate select in if.true branch in test_01, but unable
to do the same in test_02. Apparently it does not understand that "cond1 &
cond2" implies "cond1" and "cond2". Reproducer:
opt -early-cse -S ./test.ll
; ModuleID = './test.ll'
source_filename = "./test.ll"
define i32 @test_01(i32 %a, i32 %b) {
entry:
%cond = icmp slt i32 %a, %b
br i1 %cond, label %if.true, label %if.false
if.true: ; preds = %entry
ret i32 %a
if.false: ; preds = %entry
ret i32 %b
}
define i32 @test_02(i32 %a, i32 %b, i1 %c) {
entry:
%cond = icmp slt i32 %a, %b
%and.cond = and i1 %cond, %c
br i1 %and.cond, label %if.true, label %if.false
if.true: ; preds = %entry
%x = select i1 %cond, i32 %a, i32 %b
ret i32 %x
if.false: ; preds = %entry
%y = select i1 %cond, i32 %a, i32 %b
ret i32 %y
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>