[all-commits] [llvm/llvm-project] a2a58d: Revert "X86InstrInfo: Support immediates that are ...

Hans via All-commits all-commits at lists.llvm.org
Wed Nov 3 09:01:59 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a2a58d91e82db38fbdf88cc317dcb3753d79d492
      https://github.com/llvm/llvm-project/commit/a2a58d91e82db38fbdf88cc317dcb3753d79d492
  Author: Hans Wennborg <hans at chromium.org>
  Date:   2021-11-03 (Wed, 03 Nov 2021)

  Changed paths:
    M llvm/lib/Target/X86/X86InstrInfo.cpp
    M llvm/lib/Target/X86/X86InstrInfo.h
    M llvm/test/CodeGen/X86/optimize-compare.mir
    R llvm/test/CodeGen/X86/peep-test-5.ll
    M llvm/test/CodeGen/X86/use-cr-result-of-dom-icmp-st.ll

  Log Message:
  -----------
  Revert "X86InstrInfo: Support immediates that are +1/-1 different in optimizeCompareInstr"

This casued miscompiles of switches, see comments on the code review.

> This extends `optimizeCompareInstr` to re-use previous comparison
> results if the previous comparison was with an immediate that was 1
> bigger or smaller. Example:
>
>     CMP x, 13
>     ...
>     CMP x, 12   ; can be removed if we change the SETg
>     SETg ...    ; x > 12  changed to `SETge` (x >= 13) removing CMP
>
> Motivation: This often happens because SelectionDAG canonicalization
> tends to add/subtract 1 often when optimizing for fallthrough blocks.
> Example for `x > C` the fallthrough optimization switches true/false
> blocks with `!(x > C)` --> `x <= C` and canonicalization turns this into
> `x < C + 1`.
>
> Differential Revision: https://reviews.llvm.org/D110867

This reverts commit e2c7ee0743592e39274e28dbe0d0c213ba342317.




More information about the All-commits mailing list