[all-commits] [llvm/llvm-project] 0bcfaf: [SeparateConstOffsetFromGEP] Fix: sext(a) + sext(b...

Andrew Wock via All-commits all-commits at lists.llvm.org
Fri Jan 17 09:23:56 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0bcfafc5e71d4f636d456317a3a2e6fd903d4755
      https://github.com/llvm/llvm-project/commit/0bcfafc5e71d4f636d456317a3a2e6fd903d4755
  Author: Drew Wock <ajwock at gmail.com>
  Date:   2020-01-17 (Fri, 17 Jan 2020)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
    A llvm/test/Transforms/SeparateConstOffsetFromGEP/test-add-sub-separation.ll

  Log Message:
  -----------
  [SeparateConstOffsetFromGEP] Fix: sext(a) + sext(b) -> sext(a + b) matches add and sub instructions with one another

During the SeparateConstOffsetFromGEP pass, signed extensions are distributed
to the values that feed into them and then later recombined. The recombination
stage is somewhat problematic- it doesn't differ add and sub instructions
from another when matching the sext(a) +/- sext(b) -> sext(a +/- b) pattern
in some instances.

An example- the IR contains:
%unextendedA
%unextendedB
%subuAuB = unextendedA - unextendedB
%extA = extend A
%extB = extend B
%addeAeB = extA + extB

The problematic optimization will transform that into:

%unextendedA
%unextendedB
%subuAuB = unextendedA - unextendedB
%extA = extend A
%extB = extend B
%addeAeB = extend subuAuB ; Obviously not semantically equivalent to the IR input.

This patch fixes that.

Patch by Drew Wock <drew.wock at sas.com>
Differential Revision: https://reviews.llvm.org/D65967




More information about the All-commits mailing list