[all-commits] [llvm/llvm-project] 836305: [InstCombine] add tests for zext-of-signbit test; NFC

Sanjay Patel via All-commits all-commits at lists.llvm.org
Mon May 16 09:56:18 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 836305b24ca7a0dea0f80873bfa79d417d4d798d
      https://github.com/llvm/llvm-project/commit/836305b24ca7a0dea0f80873bfa79d417d4d798d
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-05-16 (Mon, 16 May 2022)

  Changed paths:
    M llvm/test/Transforms/InstCombine/zext.ll

  Log Message:
  -----------
  [InstCombine] add tests for zext-of-signbit test; NFC


  Commit: 3794cc0e996481e10307b67c8436aa44e0d65d22
      https://github.com/llvm/llvm-project/commit/3794cc0e996481e10307b67c8436aa44e0d65d22
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2022-05-16 (Mon, 16 May 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    M llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
    M llvm/test/Transforms/InstCombine/and-xor-merge.ll
    M llvm/test/Transforms/InstCombine/compare-signs.ll
    M llvm/test/Transforms/InstCombine/icmp.ll
    M llvm/test/Transforms/InstCombine/xor.ll
    M llvm/test/Transforms/InstCombine/zext.ll
    M llvm/test/Transforms/PhaseOrdering/cmp-logic.ll

  Log Message:
  -----------
  [InstCombine] invert canonicalization for cast of signbit test

The existing transform was wrong in 3 ways:
1. It created an extra instruction when the source and dest types don't match.
2. It did not account for an extra use of the icmp, so could create 2 extra insts.
3. It favored bit hacks over icmp (icmp generally has better analysis).

This fixes #54692 (modeled by the PhaseOrdering tests).

This is a minimal step to fix the bug, but we should likely invert
the sibling transform for the "is negative" pattern too.

The backend should be able to invert this back to a shift if that
leads to better codegen.


Compare: https://github.com/llvm/llvm-project/compare/74f6ded49d8c...3794cc0e9964


More information about the All-commits mailing list