https://bugs.llvm.org/show_bug.cgi?id=40683

            Bug ID: 40683
           Summary: [OptimizePHIs + Expensive Checks]  Bad machine code:
                    Virtual register killed in block, but needed live out.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Created attachment 21465
  --> https://bugs.llvm.org/attachment.cgi?id=21465&action=edit
reduced testcase

bin/llc -mcpu=z10 -O3 tc_vregkill_liveout.ll -o -

*** Bad machine code: Virtual register killed in block, but needed live out.
***
- function:    main
- basic block: %bb.2  (0x2aa66bceb88)
Virtual register %1 is used after the block.
LLVM ERROR: Found 1 machine code errors.

It seems that "Optimize machine instruction PHIs" is transforming this block,
which is inside a loop:

bb.2 (%ir-block.3):
; predecessors: %bb.1, %bb.3
  successors: %bb.4(0x40000000), %bb.5(0x40000000); %bb.4(50.00%),
%bb.5(50.00%)

  %3:gr32bit = PHI %1:gr32bit, %bb.1, %0:gr32bit, %bb.3
  %4:gr32bit = IMPLICIT_DEF
  CR killed %3:gr32bit, %4:gr32bit, implicit-def $cc
  %5:gr32bit = LHI 0
  %6:gr32bit = LHI -10
  BRC 14, 4, %bb.4, implicit $cc

to

bb.2 (%ir-block.3):
; predecessors: %bb.1, %bb.3
  successors: %bb.4(0x40000000), %bb.5(0x40000000); %bb.4(50.00%),
%bb.5(50.00%)

  %4:gr32bit = IMPLICIT_DEF
  CR killed %1:gr32bit, %4:gr32bit, implicit-def $cc
  %5:gr32bit = LHI 0
  %6:gr32bit = LHI -10
  BRC 14, 4, %bb.4, implicit $cc

Both %1 and %0 are defined outside the loop, and %0 is a copy of %1. %1 should
not have the kill flag since it is used in the next iteration as well.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to