reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc  -O0 -mtriple=mipsel-linux-gnu -global-isel  -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32
define i32 @add_i32(i32 %x, i32 %y) {
; MIPS32-LABEL: add_i32:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $2, $4, $5
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %z = add i32 %x, %y
  ret i32 %z
}

define signext i8 @add_i8_sext(i8 signext %a, i8 signext %b) {
; MIPS32-LABEL: add_i8_sext:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $1, $5, $4
; MIPS32-NEXT:    sll $1, $1, 24
; MIPS32-NEXT:    sra $2, $1, 24
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i8 %b, %a
  ret i8 %add
}

define zeroext i8 @add_i8_zext(i8 zeroext %a, i8 zeroext %b) {
; MIPS32-LABEL: add_i8_zext:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $1, $5, $4
; MIPS32-NEXT:    ori $2, $zero, 255
; MIPS32-NEXT:    and $2, $1, $2
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i8 %b, %a
  ret i8 %add
}

define i8 @add_i8_aext(i8 %a, i8 %b) {
; MIPS32-LABEL: add_i8_aext:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $2, $5, $4
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i8 %b, %a
  ret i8 %add
}

define signext i16 @add_i16_sext(i16 signext %a, i16 signext %b) {
; MIPS32-LABEL: add_i16_sext:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $1, $5, $4
; MIPS32-NEXT:    sll $1, $1, 16
; MIPS32-NEXT:    sra $2, $1, 16
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i16 %b, %a
  ret i16 %add
}

define zeroext i16 @add_i16_zext(i16 zeroext %a, i16 zeroext %b) {
; MIPS32-LABEL: add_i16_zext:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $1, $5, $4
; MIPS32-NEXT:    ori $2, $zero, 65535
; MIPS32-NEXT:    and $2, $1, $2
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i16 %b, %a
  ret i16 %add
}

define i16 @add_i16_aext(i16 %a, i16 %b) {
; MIPS32-LABEL: add_i16_aext:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $2, $5, $4
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i16 %b, %a
  ret i16 %add
}

define i64 @add_i64(i64 %a, i64 %b) {
; MIPS32-LABEL: add_i64:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addu $1, $6, $4
; MIPS32-NEXT:    sltu $2, $1, $4
; MIPS32-NEXT:    addu $3, $7, $5
; MIPS32-NEXT:    ori $4, $zero, 1
; MIPS32-NEXT:    and $2, $2, $4
; MIPS32-NEXT:    addu $3, $3, $2
; MIPS32-NEXT:    move $2, $1
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i64 %b, %a
  ret i64 %add
}

define i128 @add_i128(i128 %a, i128 %b) {
; MIPS32-LABEL: add_i128:
; MIPS32:       # %bb.0: # %entry
; MIPS32-NEXT:    addiu $sp, $sp, -8
; MIPS32-NEXT:    .cfi_def_cfa_offset 8
; MIPS32-NEXT:    addiu $1, $sp, 24
; MIPS32-NEXT:    lw $1, 0($1)
; MIPS32-NEXT:    addiu $2, $sp, 28
; MIPS32-NEXT:    lw $2, 0($2)
; MIPS32-NEXT:    addiu $3, $sp, 32
; MIPS32-NEXT:    lw $3, 0($3)
; MIPS32-NEXT:    addiu $8, $sp, 36
; MIPS32-NEXT:    lw $8, 0($8)
; MIPS32-NEXT:    addu $1, $1, $4
; MIPS32-NEXT:    sltu $4, $1, $4
; MIPS32-NEXT:    addu $5, $2, $5
; MIPS32-NEXT:    ori $9, $zero, 1
; MIPS32-NEXT:    and $4, $4, $9
; MIPS32-NEXT:    addu $4, $5, $4
; MIPS32-NEXT:    sltu $2, $4, $2
; MIPS32-NEXT:    addu $5, $3, $6
; MIPS32-NEXT:    and $2, $2, $9
; MIPS32-NEXT:    addu $2, $5, $2
; MIPS32-NEXT:    sltu $3, $2, $3
; MIPS32-NEXT:    addu $5, $8, $7
; MIPS32-NEXT:    and $3, $3, $9
; MIPS32-NEXT:    addu $5, $5, $3
; MIPS32-NEXT:    sw $2, 4($sp) # 4-byte Folded Spill
; MIPS32-NEXT:    move $2, $1
; MIPS32-NEXT:    move $3, $4
; MIPS32-NEXT:    lw $4, 4($sp) # 4-byte Folded Reload
; MIPS32-NEXT:    addiu $sp, $sp, 8
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
entry:
  %add = add i128 %b, %a
  ret i128 %add
}

declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32)
define void @uadd_with_overflow(i32 %lhs, i32 %rhs, i32* %padd, i1* %pcarry_flag) {
; MIPS32-LABEL: uadd_with_overflow:
; MIPS32:       # %bb.0:
; MIPS32-NEXT:    addu $1, $4, $5
; MIPS32-NEXT:    sltu $2, $1, $5
; MIPS32-NEXT:    ori $3, $zero, 1
; MIPS32-NEXT:    and $2, $2, $3
; MIPS32-NEXT:    sb $2, 0($7)
; MIPS32-NEXT:    sw $1, 0($6)
; MIPS32-NEXT:    jr $ra
; MIPS32-NEXT:    nop
  %res = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %lhs, i32 %rhs)
  %carry_flag = extractvalue { i32, i1 } %res, 1
  %add = extractvalue { i32, i1 } %res, 0
  store i1 %carry_flag, i1* %pcarry_flag
  store i32 %add, i32* %padd
  ret void
}