1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv64 -mattr=+m -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefixes=NO-PREFER-W-INST %s
; RUN: llc -mtriple=riscv64 -mattr=+m -riscv-disable-strip-w-suffix -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefixes=NO-STRIP %s
; RUN: llc -mtriple=riscv64 -mattr=+m,+prefer-w-inst -verify-machineinstrs < %s \
; RUN: | FileCheck -check-prefixes=PREFER-W-INST %s
define i32 @addiw(i32 %a) {
; NO-PREFER-W-INST-LABEL: addiw:
; NO-PREFER-W-INST: # %bb.0:
; NO-PREFER-W-INST-NEXT: lui a1, 1
; NO-PREFER-W-INST-NEXT: addi a1, a1, -1
; NO-PREFER-W-INST-NEXT: addw a0, a0, a1
; NO-PREFER-W-INST-NEXT: ret
;
; NO-STRIP-LABEL: addiw:
; NO-STRIP: # %bb.0:
; NO-STRIP-NEXT: lui a1, 1
; NO-STRIP-NEXT: addiw a1, a1, -1
; NO-STRIP-NEXT: addw a0, a0, a1
; NO-STRIP-NEXT: ret
;
; PREFER-W-INST-LABEL: addiw:
; PREFER-W-INST: # %bb.0:
; PREFER-W-INST-NEXT: lui a1, 1
; PREFER-W-INST-NEXT: addiw a1, a1, -1
; PREFER-W-INST-NEXT: addw a0, a0, a1
; PREFER-W-INST-NEXT: ret
%ret = add i32 %a, 4095
ret i32 %ret
}
define i32 @addw(i32 %a, i32 %b) {
; NO-PREFER-W-INST-LABEL: addw:
; NO-PREFER-W-INST: # %bb.0:
; NO-PREFER-W-INST-NEXT: add a0, a0, a1
; NO-PREFER-W-INST-NEXT: addiw a0, a0, 1024
; NO-PREFER-W-INST-NEXT: ret
;
; NO-STRIP-LABEL: addw:
; NO-STRIP: # %bb.0:
; NO-STRIP-NEXT: addw a0, a0, a1
; NO-STRIP-NEXT: addiw a0, a0, 1024
; NO-STRIP-NEXT: ret
;
; PREFER-W-INST-LABEL: addw:
; PREFER-W-INST: # %bb.0:
; PREFER-W-INST-NEXT: addw a0, a0, a1
; PREFER-W-INST-NEXT: addiw a0, a0, 1024
; PREFER-W-INST-NEXT: ret
%add = add i32 %a, %b
%ret = add i32 %add, 1024
ret i32 %ret
}
define i32 @mulw(i32 %a, i32 %b) {
; NO-PREFER-W-INST-LABEL: mulw:
; NO-PREFER-W-INST: # %bb.0:
; NO-PREFER-W-INST-NEXT: mul a1, a0, a1
; NO-PREFER-W-INST-NEXT: mul a0, a0, a1
; NO-PREFER-W-INST-NEXT: addiw a0, a0, 1024
; NO-PREFER-W-INST-NEXT: ret
;
; NO-STRIP-LABEL: mulw:
; NO-STRIP: # %bb.0:
; NO-STRIP-NEXT: mulw a1, a0, a1
; NO-STRIP-NEXT: mulw a0, a0, a1
; NO-STRIP-NEXT: addiw a0, a0, 1024
; NO-STRIP-NEXT: ret
;
; PREFER-W-INST-LABEL: mulw:
; PREFER-W-INST: # %bb.0:
; PREFER-W-INST-NEXT: mulw a1, a0, a1
; PREFER-W-INST-NEXT: mulw a0, a0, a1
; PREFER-W-INST-NEXT: addiw a0, a0, 1024
; PREFER-W-INST-NEXT: ret
%mul1 = mul i32 %a, %b
%mul = mul i32 %a, %mul1
%ret = add i32 %mul, 1024
ret i32 %ret
}
define i32 @slliw(i32 %a) {
; NO-PREFER-W-INST-LABEL: slliw:
; NO-PREFER-W-INST: # %bb.0:
; NO-PREFER-W-INST-NEXT: slli a0, a0, 1
; NO-PREFER-W-INST-NEXT: addiw a0, a0, 1024
; NO-PREFER-W-INST-NEXT: ret
;
; NO-STRIP-LABEL: slliw:
; NO-STRIP: # %bb.0:
; NO-STRIP-NEXT: slliw a0, a0, 1
; NO-STRIP-NEXT: addiw a0, a0, 1024
; NO-STRIP-NEXT: ret
;
; PREFER-W-INST-LABEL: slliw:
; PREFER-W-INST: # %bb.0:
; PREFER-W-INST-NEXT: slliw a0, a0, 1
; PREFER-W-INST-NEXT: addiw a0, a0, 1024
; PREFER-W-INST-NEXT: ret
%shl = shl i32 %a, 1
%ret = add i32 %shl, 1024
ret i32 %ret
}
|