[PATCH] D113442: [InstCombine] Enable fold select into operand for FAdd, FMul, FSub and FDiv.

LuoYuanke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 29 19:29:56 PST 2022


LuoYuanke added a comment.

> Note that this patch makes IR more consistent (FP ops are treated the same as integer ops). So is the integer codegen also not optimal?
> https://godbolt.org/z/jd3q6Yq55

I think the integer is also optimal with AVX512 target. See https://godbolt.org/z/Wahef3b3v. For _mm_mask_add_epi64() and _mm_mask_sub_epi64(), it eventually generate extra instructions. But for integer mul, or, and, xor and shl in the test case the InstCombinePass doesn't transform it, so it still generate good code.

I still don't understand what's the benefit to move select instruction before the binary operation (add, sub, mul ...).  Can someone indicate why it is profitable? If it is profitable for general case, I think we can call TTI interface to ask backend if the transform is profitable and then make the decision to transform. We may add below interfaces in TTI.

  +
  +  bool isLegalMaskedFAdd(Type *DataTye);
  +  bool isLegalMaskedFSub(Type *DataTye);
  +  bool isLegalMaskedFMul(Type *DataTye);
  +  bool isLegalMaskedFDiv(Type *DataTye);
  +




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113442/new/

https://reviews.llvm.org/D113442



More information about the llvm-commits mailing list