[all-commits] [llvm/llvm-project] baadbe: [X86] Fold cmpeq/ne(trunc(logic(x)), 0) --> cmpeq/n...

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Mon Apr 12 08:06:01 PDT 2021


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

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/2012-08-16-setcc.ll
    M llvm/test/CodeGen/X86/and-with-overflow.ll
    M llvm/test/CodeGen/X86/jump_sign.ll
    M llvm/test/CodeGen/X86/or-with-overflow.ll
    M llvm/test/CodeGen/X86/xor-with-overflow.ll

  Log Message:
  -----------
  [X86] Fold cmpeq/ne(trunc(logic(x)),0) --> cmpeq/ne(logic(x),0)

Fixes the issues noted in PR48768, where the and/or/xor instruction had been promoted to avoid i8/i16 partial-dependencies, but the test against zero had not.

We can almost certainly relax this fold to work for any truncation, although it breaks a number of existing folds (notable movmsk folds which tend to rely on the truncate to determine the demanded bits/elts in the source vector).

There is a reverse combine in TargetLowering.SimplifySetCC so we must wait until after legalization before attempting this.


  Commit: 9c9df057503d72e6e559a63e39cba73881acfa3f
      https://github.com/llvm/llvm-project/commit/9c9df057503d72e6e559a63e39cba73881acfa3f
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-04-12 (Mon, 12 Apr 2021)

  Changed paths:
    M llvm/test/Transforms/InstCombine/select-ctlz-to-cttz.ll

  Log Message:
  -----------
  [InstCombine] Regenerate select-ctlz-to-cttz.ll tests

Correctly test !range metadata


Compare: https://github.com/llvm/llvm-project/compare/a46effbd2aec...9c9df057503d


More information about the All-commits mailing list