https://bugs.llvm.org/show_bug.cgi?id=34228

            Bug ID: 34228
           Summary: Optimizer doesn't eliminate select with two equivalent
                    operands
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: m...@manueljacob.de
                CC: llvm-bugs@lists.llvm.org

The following transformation doesn't happen:

%shared = add i64 %x, %y
%r1 = select i1 %c1, i64 %shared, i64 %x
%r2 = select i1 %c2, i64 %shared, i64 %y
%tmp = select i1 %c2, i64 %x, i64 0
%r2_eq1 = add i64 %tmp, %y
%r2_eq2 = select i1 %zzz, i64 %r2, i64 %r2_eq1
%r = add i64 %r1, %r2_eq2
  =>
%shared = add i64 %x, %y
%r1 = select i1 %c1, i64 %shared, i64 %x
%r2 = select i1 %c2, i64 %shared, i64 %y
%r = add i64 %r1, %r2

http://rise4fun.com/Alive/IOS5

InstCombine can do the following canonicalization (see comment in
`getSelectFoldableOperands()`):

%shared = add i64 %x, %y
%r2 = select i1 %c2, i64 %shared, i64 %y
  =>
%tmp = select i1 %c2, i64 %x, i64 0
%r2 = add i64 %tmp, %y

But in this case the canonicalization doesn't happen, because %shared has two
uses.  Note that %r2_eq1 actually is the canonical form of %r2.  Further
canonicalization of either %r2 or %r2_eq1 won't happen.  This is why the
optimizer doesn't see that %r2_eq2 selects between two equivalent operands (and
is therefore equal to %r2).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to