legalizer-combiner-zext-trunc-crash.mir 2.68 KB
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple aarch64 -run-pass=legalizer -verify-machineinstrs %s -o - | FileCheck %s

# This test checks we don't crash when doing zext(trunc) legalizer combines.
---
name:            zext_trunc_dead_inst_crash
alignment:       4
tracksRegLiveness: true
body:             |
  ; CHECK-LABEL: name: zext_trunc_dead_inst_crash
  ; CHECK: bb.0:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   [[DEF:%[0-9]+]]:_(s16) = G_IMPLICIT_DEF
  ; CHECK: bb.1:
  ; CHECK:   successors: %bb.2(0x80000000)
  ; CHECK:   [[PHI:%[0-9]+]]:_(s16) = G_PHI %32(s16), %bb.2, [[DEF]](s16), %bb.0
  ; CHECK:   [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
  ; CHECK:   [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[PHI]](s16)
  ; CHECK:   [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C]]
  ; CHECK:   [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 46
  ; CHECK:   [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(eq), [[AND]](s32), [[C1]]
  ; CHECK:   [[COPY:%[0-9]+]]:_(s32) = COPY [[ICMP]](s32)
  ; CHECK:   [[DEF1:%[0-9]+]]:_(s32) = G_IMPLICIT_DEF
  ; CHECK:   [[OR:%[0-9]+]]:_(s32) = G_OR [[COPY]], [[DEF1]]
  ; CHECK:   [[COPY1:%[0-9]+]]:_(s32) = COPY [[ANYEXT]](s32)
  ; CHECK:   [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 -33
  ; CHECK:   [[AND1:%[0-9]+]]:_(s32) = G_AND [[COPY1]], [[C2]]
  ; CHECK:   [[COPY2:%[0-9]+]]:_(s32) = COPY [[AND1]](s32)
  ; CHECK:   [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 -65
  ; CHECK:   [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY2]], [[C3]]
  ; CHECK:   [[COPY3:%[0-9]+]]:_(s32) = COPY [[ADD]](s32)
  ; CHECK:   [[AND2:%[0-9]+]]:_(s32) = G_AND [[COPY3]], [[C]]
  ; CHECK:   [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 26
  ; CHECK:   [[ICMP1:%[0-9]+]]:_(s32) = G_ICMP intpred(ult), [[AND2]](s32), [[C4]]
  ; CHECK:   [[COPY4:%[0-9]+]]:_(s32) = COPY [[ICMP1]](s32)
  ; CHECK:   [[COPY5:%[0-9]+]]:_(s32) = COPY [[OR]](s32)
  ; CHECK:   [[OR1:%[0-9]+]]:_(s32) = G_OR [[COPY4]], [[COPY5]]
  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s1) = G_TRUNC [[OR1]](s32)
  ; CHECK:   G_BRCOND [[TRUNC]](s1), %bb.2
  ; CHECK: bb.2:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   [[C5:%[0-9]+]]:_(s16) = G_CONSTANT i16 64
  ; CHECK:   G_BR %bb.1
  bb.1:
    %1:_(s8) = G_CONSTANT i8 46
    %3:_(s1) = G_IMPLICIT_DEF
    %5:_(s8) = G_CONSTANT i8 -33
    %7:_(s8) = G_CONSTANT i8 -65
    %9:_(s8) = G_CONSTANT i8 26
    %13:_(s8) = G_IMPLICIT_DEF

  bb.2:
    %0:_(s8) = G_PHI %12(s8), %bb.4, %13(s8), %bb.1
    %2:_(s1) = G_ICMP intpred(eq), %0(s8), %1
    %4:_(s1) = G_OR %2, %3
    %6:_(s8) = G_AND %0, %5
    %8:_(s8) = G_ADD %6, %7
    %10:_(s1) = G_ICMP intpred(ult), %8(s8), %9
    %11:_(s1) = G_OR %10, %4
    G_BRCOND %11(s1), %bb.4

  bb.4:
    %12:_(s8) = G_CONSTANT i8 64
    G_BR %bb.2

...