[PATCH] D127840: [MachinePipeliner] Fix Phi generation failure for large stages

Yuta Mukai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 18:27:12 PDT 2022


ytmukai added a comment.

Here are more details about the failure.
The code below is the original code for the added test case.

  void f(float *restrict a, float *b, int n) {
  #pragma clang loop pipeline_initiation_interval(3)
    for (int i=0; i<n; i++)
      a[i] = b[i]+1+b[i];
  }

The current code produces the following error.

  $ clang test.c --target=powerpc64le-unknown-linux-gnu -mcpu=pwr9 -mllvm --ppc-enable-pipeliner -mllvm -pipeliner-max-stages=10 -mllvm -verify-machineinstrs -O -c
  ...
  bb.9.for.body:
  ...
    %42:f4rc, %43:g8rc_and_g8rc_nox0 = LFSU 4, %39:g8rc_and_g8rc_nox0(tied-def 1) :: (load unknown-size from %ir.3, align 4, !tbaa !5)
  ...
  bb.12:
  ...
    %72:f4rc = PHI %47:f4rc, %bb.10, %51:f4rc, %bb.11
    %73:f4rc = PHI %42:f4rc, %bb.10, %59:f4rc, %bb.11
    %74:f4rc = PHI %37:f4rc, %bb.10, %60:f4rc, %bb.11
    %75:f4rc = PHI %32:f4rc, %bb.10, %61:f4rc, %bb.11
  ...
  bb.13:
  ...
    %85:f4rc = PHI %75:f4rc, %bb.9, %72:f4rc, %bb.12
    %86:f4rc = PHI %37:f4rc, %bb.9, %73:f4rc, %bb.12
    %87:f4rc = PHI %32:f4rc, %bb.9, %74:f4rc, %bb.12
    %88:f4rc = PHI %28:f4rc, %bb.9, %75:f4rc, %bb.12
  ...
  *** Bad machine code: PHI operand is not live-out from predecessor ***
  - function:    f
  - basic block: %bb.13  (0x5645be4f36e0)
  - instruction: %85:f4rc = PHI %75:f4rc, %bb.9, %72:f4rc, %bb.12
  - operand 1:   %75:f4rc
  
  *** Bad machine code: Virtual register defs don't dominate all uses. ***
  - function:    f
  - v. register: %75
  ...

The Phi operand from `bb.9` must be `%42`, but is overwritten by `%75` in `bb.12`.
This error may not occur under the default maximum number of stages (3).
However, I would like to use pipelining with a larger number of stages.

This change does not affect the generated code for the existing success cases (confirmed by the CodeGen tests for Hexagon, PowerPC and ARM).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127840/new/

https://reviews.llvm.org/D127840



More information about the llvm-commits mailing list