llvm/llvm/test/CodeGen/RISCV/prefer-w-inst.mir

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
# RUN: llc %s -mtriple=riscv64 -run-pass=riscv-opt-w-instrs -verify-machineinstrs \
# RUN:   -mattr=+m -o - | FileCheck %s -check-prefixes=NO-PREFER-W-INST
# RUN: llc %s -mtriple=riscv64 -run-pass=riscv-opt-w-instrs -verify-machineinstrs \
# RUN:   -mattr=+m,+prefer-w-inst -o - | FileCheck %s -check-prefixes=PREFER-W-INST

---
name: addi
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: addi
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[ADDI:%[0-9]+]]:gpr = ADDI [[COPY]], 1
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[ADDI]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: addi
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[COPY]], 1
    ; PREFER-W-INST-NEXT: [[ADDIW1:%[0-9]+]]:gpr = ADDIW [[ADDIW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW1]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = ADDI %1, 1
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...

---
name: add
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: add
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[ADD:%[0-9]+]]:gpr = ADD [[COPY]], [[COPY1]]
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[ADD]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: add
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[ADDW:%[0-9]+]]:gpr = ADDW [[COPY]], [[COPY1]]
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[ADDW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = ADD %1, %2
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...

---
name: sub
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: sub
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[SUB:%[0-9]+]]:gpr = SUB [[COPY]], [[COPY1]]
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[SUB]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: sub
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[SUBW:%[0-9]+]]:gpr = SUBW [[COPY]], [[COPY1]]
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[SUBW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = SUB %1, %2
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...

---
name: mul
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: mul
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[MUL:%[0-9]+]]:gpr = MUL [[COPY]], [[COPY1]]
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[MUL]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: mul
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[MULW:%[0-9]+]]:gpr = MULW [[COPY]], [[COPY1]]
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[MULW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = MUL %1, %2
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...


---
name: slli_31
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: slli_31
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[COPY]], 31
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[SLLI]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: slli_31
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[SLLIW:%[0-9]+]]:gpr = SLLIW [[COPY]], 31
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[SLLIW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = SLLI %1, 31
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...

---
name: slli_32
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: slli_32
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[COPY]], 32
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[SLLI]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: slli_32
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[SLLI:%[0-9]+]]:gpr = SLLI [[COPY]], 32
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[SLLI]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = SLLI %1, 32
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...

---
name: ld
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: ld
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[LD:%[0-9]+]]:gpr = LD [[COPY]], 0
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[LD]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: ld
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[LW:%[0-9]+]]:gpr = LW [[COPY]], 0
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[LW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = LD %1, 0
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...

---
name: lwu
body:             |
  bb.0.entry:
    liveins: $x10, $x11
    ; NO-PREFER-W-INST-LABEL: name: lwu
    ; NO-PREFER-W-INST: liveins: $x10, $x11
    ; NO-PREFER-W-INST-NEXT: {{  $}}
    ; NO-PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; NO-PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; NO-PREFER-W-INST-NEXT: [[LWU:%[0-9]+]]:gpr = LWU [[COPY]], 0
    ; NO-PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[LWU]], 1
    ; NO-PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; NO-PREFER-W-INST-NEXT: PseudoRET
    ;
    ; PREFER-W-INST-LABEL: name: lwu
    ; PREFER-W-INST: liveins: $x10, $x11
    ; PREFER-W-INST-NEXT: {{  $}}
    ; PREFER-W-INST-NEXT: [[COPY:%[0-9]+]]:gpr = COPY $x10
    ; PREFER-W-INST-NEXT: [[COPY1:%[0-9]+]]:gpr = COPY $x11
    ; PREFER-W-INST-NEXT: [[LW:%[0-9]+]]:gpr = LW [[COPY]], 0
    ; PREFER-W-INST-NEXT: [[ADDIW:%[0-9]+]]:gpr = ADDIW [[LW]], 1
    ; PREFER-W-INST-NEXT: $x10 = COPY [[ADDIW]]
    ; PREFER-W-INST-NEXT: PseudoRET
    %1:gpr = COPY $x10
    %2:gpr = COPY $x11
    %3:gpr = LWU %1, 0
    %4:gpr = ADDIW %3, 1
    $x10 = COPY %4
    PseudoRET
...