Skip to content

miss to recognize two equal variables #47492

@llvmbot

Description

@llvmbot
Bugzilla Link 48148
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @ecnelises,@LebedevRI,@rotateright

Extended Description

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions