llvm/llvm/test/CodeGen/AArch64/GlobalISel/combine-const-fold-barrier-rhs.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
---
name:            cfb_lhs
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %add:_(s32) = G_ADD [[COPY]], %cfb
    ; CHECK-NEXT: $w0 = COPY %add(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 2
    %add:_(s32) = G_ADD %cfb, %0
    $w0 = COPY %add
    RET_ReallyLR

...
---
name:            cfb_lhs_cfb_already_rhs
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_cfb_already_rhs
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %cst2:_(s32) = G_CONSTANT i32 2
    ; CHECK-NEXT: %cfb2:_(s32) = G_CONSTANT_FOLD_BARRIER %cst2
    ; CHECK-NEXT: %add:_(s32) = G_ADD %cfb, %cfb2
    ; CHECK-NEXT: $w0 = COPY %add(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 2
    %cfb2:_(s32) = G_CONSTANT_FOLD_BARRIER %cst2
    %add:_(s32) = G_ADD %cfb, %cfb2
    $w0 = COPY %add
    RET_ReallyLR

...
---
name:            cfb_lhs_cst_on_rhs
alignment:       4
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_cst_on_rhs
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %cst2:_(s32) = G_CONSTANT i32 2
    ; CHECK-NEXT: %add:_(s32) = G_ADD %cfb, %cst2
    ; CHECK-NEXT: $w0 = COPY %add(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 2
    %add:_(s32) = G_ADD %cfb, %cst2
    $w0 = COPY %add
    RET_ReallyLR

...
---
name:            cfb_lhs_smulo
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_smulo
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %mul:_(s32), %overflow:_(s1) = G_SMULO [[COPY]], %cfb
    ; CHECK-NEXT: %ret:_(s32) = G_ANYEXT %overflow(s1)
    ; CHECK-NEXT: $w0 = COPY %ret(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %mul:_(s32), %overflow:_(s1) = G_SMULO %cfb, %0
    %ret:_(s32) = G_ANYEXT %overflow
    $w0 = COPY %ret
    RET_ReallyLR

...
---
name:            cfb_lhs_cfb_already_rhs_smulo
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_cfb_already_rhs_smulo
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %cst2:_(s32) = G_CONSTANT i32 6
    ; CHECK-NEXT: %cfb2:_(s32) = G_CONSTANT_FOLD_BARRIER %cst2
    ; CHECK-NEXT: %mul:_(s32), %overflow:_(s1) = G_SMULO %cfb, %cfb2
    ; CHECK-NEXT: %ret:_(s32) = G_ANYEXT %overflow(s1)
    ; CHECK-NEXT: $w0 = COPY %ret(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 6
    %cfb2:_(s32) = G_CONSTANT_FOLD_BARRIER %cst2
    %mul:_(s32), %overflow:_(s1) = G_SMULO %cfb, %cfb2
    %ret:_(s32) = G_ANYEXT %overflow
    $w0 = COPY %ret
    RET_ReallyLR

...
---
name:            cfb_lhs_cst_on_rhs_smulo
alignment:       4
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_cst_on_rhs_smulo
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %cst2:_(s32) = G_CONSTANT i32 6
    ; CHECK-NEXT: %mul:_(s32), %overflow:_(s1) = G_SMULO %cfb, %cst2
    ; CHECK-NEXT: %ret:_(s32) = G_ANYEXT %overflow(s1)
    ; CHECK-NEXT: $w0 = COPY %ret(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 6
    %mul:_(s32), %overflow:_(s1) = G_SMULO %cfb, %cst2
    %ret:_(s32) = G_ANYEXT %overflow
    $w0 = COPY %ret
    RET_ReallyLR

...
---
name:            cfb_lhs_umulfixsat
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_umulfixsat
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %mul:_(s32) = G_UMULFIXSAT [[COPY]], %cfb, 7
    ; CHECK-NEXT: $w0 = COPY %mul(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %mul:_(s32) = G_UMULFIXSAT %cfb, %0, 7
    $w0 = COPY %mul
    RET_ReallyLR

...
---
name:            cfb_lhs_cfb_already_rhs_umulfixsat
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_cfb_already_rhs_umulfixsat
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %cst2:_(s32) = G_CONSTANT i32 2
    ; CHECK-NEXT: %cfb2:_(s32) = G_CONSTANT_FOLD_BARRIER %cst2
    ; CHECK-NEXT: %add:_(s32) = G_UMULFIXSAT %cfb, %cfb2, 7
    ; CHECK-NEXT: $w0 = COPY %add(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 2
    %cfb2:_(s32) = G_CONSTANT_FOLD_BARRIER %cst2
    %add:_(s32) = G_UMULFIXSAT %cfb, %cfb2, 7
    $w0 = COPY %add
    RET_ReallyLR

...
---
name:            cfb_lhs_cst_on_rhs_umulfixsat
alignment:       4
tracksRegLiveness: true
body:             |
  bb.1:
    liveins: $w0

    ; CHECK-LABEL: name: cfb_lhs_cst_on_rhs_umulfixsat
    ; CHECK: liveins: $w0
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: %cst:_(s32) = G_CONSTANT i32 1
    ; CHECK-NEXT: %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    ; CHECK-NEXT: %cst2:_(s32) = G_CONSTANT i32 2
    ; CHECK-NEXT: %add:_(s32) = G_UMULFIXSAT %cfb, %cst2, 7
    ; CHECK-NEXT: $w0 = COPY %add(s32)
    ; CHECK-NEXT: RET_ReallyLR
    %0:_(s32) = COPY $w0
    %cst:_(s32) = G_CONSTANT i32 1
    %cfb:_(s32) = G_CONSTANT_FOLD_BARRIER %cst
    %cst2:_(s32) = G_CONSTANT i32 2
    %add:_(s32) = G_UMULFIXSAT %cfb, %cst2, 7
    $w0 = COPY %add
    RET_ReallyLR

...