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: unassignedb...@nondot.org
          Reporter: spatel+l...@rotateright.com
                CC: craig.top...@gmail.com, llvm-bugs@lists.llvm.org,
                    llvm-...@redking.me.uk, pengfei.w...@intel.com,
                    spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to