[llvm-bugs] [Bug 37635] New: EarlyCSE does not benefit from "and" conditions
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed May 30 20:46:37 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37635
Bug ID: 37635
Summary: EarlyCSE does not benefit from "and" conditions
Product: new-bugs
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: max.kazantsev at azul.com
CC: llvm-bugs at lists.llvm.org
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
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180531/171bd08f/attachment.html>
More information about the llvm-bugs
mailing list