[all-commits] [llvm/llvm-project] 245036: [X86][BMI] Fold cmpeq/ne(or(X, Y), X) --> cmpeq/ne(a...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Fri Apr 9 07:52:31 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 245036950a7a63f77aa1f06f46dfe2fbb2cafc0f
      https://github.com/llvm/llvm-project/commit/245036950a7a63f77aa1f06f46dfe2fbb2cafc0f
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-04-09 (Fri, 09 Apr 2021)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/setcc-logic.ll

  Log Message:
  -----------
  [X86][BMI] Fold cmpeq/ne(or(X,Y),X) --> cmpeq/ne(and(~X,Y),0) (PR44136)

I've initially just enabled this for BMI which has the ANDN instruction for i32/i64 - the i16/i8 cases give an idea of what'd we get when we enable it in all cases (I'll do this as a later commit).

Additionally, the i16/i8 cases could be freely promoted to i32 (as the args are already zeroext) and we could then make use of ANDN + the free cmp0 there as well - this has come up in PR48768 and PR49028 so I'm going to look at this soon.

https://alive2.llvm.org/ce/z/QVWHP_
https://alive2.llvm.org/ce/z/pLngT-

Vector cases do not appear to benefit from this as we end up with having to generate the zero vector as well - this is one of the reasons I didn't try to tie this into hasAndNot/hasAndNotCompare.

Differential Revision: https://reviews.llvm.org/D100177




More information about the All-commits mailing list