[llvm-bugs] [Bug 52267] New: [x86] convert xor with SMIN to add

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 22 11:35:15 PDT 2021


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

            Bug ID: 52267
           Summary: [x86] convert xor with SMIN to add
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, pengfei.wang at intel.com,
                    spatel+llvm at rotateright.com

Based on discussion in https://reviews.llvm.org/D112085 :

define i32 @add_smin(i32 %x) {
  %r = add i32 %x, 2147483648
  ret i32 %r
}

define i32 @xor_smin(i32 %x) {
  %r = xor i32 %x, 2147483648
  ret i32 %r
}

These are logically equivalent:
https://alive2.llvm.org/ce/z/qV46E2

...and instcombine chooses 'xor' for better analysis in IR. But x86 (probably
unlike most targets), may benefit from converting it back to 'add' (for legal
integer types) because that can be lowered as LEA:

  movl  %edi, %eax
  xorl  $-2147483648, %eax              ## imm = 0x80000000
vs.
  leal  -2147483648(%rdi), %eax

-- 
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/20211022/82714362/attachment.html>


More information about the llvm-bugs mailing list