[all-commits] [llvm/llvm-project] f31d39: [InstCombine] remove cast-of-signbit to shift tran...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Tue May 17 08:12:12 PDT 2022


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

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

  Log Message:
  -----------
  [InstCombine] remove cast-of-signbit to shift transform

The 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
this and 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.

This is a reduced try of 3794cc0e9964 - that was reverted because
it could cause infinite loops by conflicting with the related
transforms in this block that create shifts.




More information about the All-commits mailing list