Issue 141643
Summary ppc-reduce-cr-ops mishandles subregister uses and emits verifier error
Labels backend:PowerPC, crash-on-valid
Assignees
Reporter arsenm
    ```
# RUN: llc -mtriple=powerpc64-unknown-linux-gnu -run-pass=ppc-reduce-cr-ops -verify-machineinstrs -o - %s

---
name: subreg_folding_regression
tracksRegLiveness: true
isSSA: true
body:             |
  bb.0:
    liveins: $x3

 %0:g8rc_and_g8rc_nox0 = COPY $x3
    %1:g8rc = LD 0, %0 :: (load (s64))

 bb.1:
    %2:g8rc_and_g8rc_nox0 = PHI %1, %bb.0, %3, %bb.1, %4, %bb.2
 %5:gprc = LBZ 0, %2 :: (load (s8))
    %6:crrc = CMPWI killed %5, 0
 %3:g8rc = nuw ADDI8 %2, 1
    STD %3, 0, %0 :: (store (s64))
    %7:gprc = LBZ 1, %2 :: (load (s8))
    %8:crrc = CMPWI killed %7, 0
    %9:crbitrc = CRORC %8.sub_eq, %6.sub_eq
    BC killed %9, %bb.1
    B %bb.2

  bb.2:
 %4:g8rc = nuw ADDI8 %2, 2
    STD %4, 0, %0 :: (store (s64))
    B %bb.1

...
```

Produces:
```
# After PowerPC Reduce CR logical Operation
# Machine code for function subreg_folding_regression: IsSSA, TracksLiveness

bb.0:
  successors: %bb.1(0x80000000); %bb.1(100.00%)
 liveins: $x3
  %0:g8rc_and_g8rc_nox0 = COPY $x3
  %1:g8rc = LD 0, %0:g8rc_and_g8rc_nox0 :: (load (s64))

bb.1:
; predecessors: %bb.0, %bb.2, %bb.3, %bb.1
  successors: %bb.1(0x20000000), %bb.3(0x60000000); %bb.1(25.00%), %bb.3(75.00%)

  %2:g8rc_and_g8rc_nox0 = PHI %1:g8rc, %bb.0, %3:g8rc, %bb.1, %4:g8rc, %bb.2, %3:g8rc, %bb.3
  %5:gprc = LBZ 0, %2:g8rc_and_g8rc_nox0 :: (load (s8))
  %6:crrc = CMPWI killed %5:gprc, 0
 %3:g8rc = nuw ADDI8 %2:g8rc_and_g8rc_nox0, 1
  STD %3:g8rc, 0, %0:g8rc_and_g8rc_nox0 :: (store (s64))
  %7:gprc = LBZ 1, %2:g8rc_and_g8rc_nox0 :: (load (s8))
  BCn %6:crrc, %bb.1
  B %bb.3

bb.3:
; predecessors: %bb.1
  successors: %bb.1(0x2aaaaaab), %bb.2(0x55555555); %bb.1(33.33%), %bb.2(66.67%)

  %8:crrc = CMPWI killed %7:gprc, 0
  BC killed %8:crrc, %bb.1
  B %bb.2

bb.2:
; predecessors: %bb.3
  successors: %bb.1(0x80000000); %bb.1(100.00%)

  %4:g8rc = nuw ADDI8 %2:g8rc_and_g8rc_nox0, 2
  STD %4:g8rc, 0, %0:g8rc_and_g8rc_nox0 :: (store (s64))
  B %bb.1

# End machine code for function subreg_folding_regression.

*** Bad machine code: Illegal virtual register for instruction ***
- function:    subreg_folding_regression
- basic block: %bb.1  (0x15a058748)
- instruction: BCn %6:crrc, %bb.1
- operand 0: %6:crrc
Expected a CRBITRC register, but got a CRRC register

*** Bad machine code: Illegal virtual register for instruction ***
- function: subreg_folding_regression
- basic block: %bb.3  (0x15a05f290)
- instruction: BC killed %8:crrc, %bb.1
- operand 0:   killed %8:crrc
Expected a CRBITRC register, but got a CRRC register
LLVM ERROR: Found 2 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to