[llvm-bugs] [Bug 51567] New: Missing transformation rotr(X, C1) == C2 --> X == C3

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Aug 20 15:03:37 PDT 2021


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

            Bug ID: 51567
           Summary: Missing transformation rotr(X,C1) == C2 --> X == C3
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

// rotr(X, C1) == C2 --> X == C3 where C3 = rotl(C2, C1)
// rotl(X,C1) == C2 --> X == C3 where C3 = rotr(C2,C1)

bool foo(unsigned int  x)
{
  unsigned int rx = rotr(x, 7);
  return rx == 5;
}


bool bar(unsigned int  x)
{
  return x == rotl(5, 7);
}

Trunk -O2:
foo(unsigned int):                                # @foo(unsigned int)
        rol     edi, 25
        cmp     edi, 5
        sete    al
        ret
bar(unsigned int):                                # @bar(unsigned int)
        cmp     edi, 640
        sete    al
        ret


Current codegen:
https://godbolt.org/z/xb1vPa5Pq

Alive:
https://alive2.llvm.org/ce/z/GdY8Jm

-- 
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/20210820/9a8a30e1/attachment-0001.html>


More information about the llvm-bugs mailing list