[llvm-bugs] [Bug 48148] New: miss to recognize two equal variables

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 10 21:47:28 PST 2020


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

            Bug ID: 48148
           Summary: miss to recognize two equal variables
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: chenzheng1030 at hotmail.com
                CC: llvm-bugs at lists.llvm.org

```
define i64 @foo1(i16 %0, i64 %1, i64 %2) {

entry:
  %cmp1 = icmp ult i16 %0, 43
  %cond1 = select i1 %cmp1, i64 %1, i64 %2
  %cmp2 = icmp ugt i16 %0, 42
  %cond2 = select i1 %cmp2, i64 %2, i64 %1
  %ret = xor i64 %cond1, %cond2
  ret i64 %ret
}
```

we should be able to recognize that `%cond1` and `%cond2` are the same, so the
function should just return zero.

Comments from Sanjay Patel:

This looks like a missed canonicalization (instcombine):
https://alive2.llvm.org/ce/z/oUDr6C

We should choose one of those forms - maybe we need to refine
InstCombiner::isCanonicalPredicate()? This could be tricky because we have many
different kinds of cmp+select canonicalizations that we already try. We will
need to make sure that we do not invert some other transform and cause an
infinite-loop.

-- 
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/20201111/2ab6dbfe/attachment.html>


More information about the llvm-bugs mailing list