; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -verify-machineinstrs -mtriple powerpc64-unknown-linux-gnu -mcpu=ppc64 < %s | FileCheck %s
; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -vec-extabi -mcpu=ppc64 < %s | FileCheck %s

; Function Attrs: nounwind readnone
define i64 @cn1() #0 {
; CHECK-LABEL: cn1:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -1
; CHECK-NEXT:    rldic 3, 3, 0, 16
; CHECK-NEXT:    blr
entry:
  ret i64 281474976710655

}

; Function Attrs: nounwind readnone
define i64 @cnb() #0 {
; CHECK-LABEL: cnb:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -81
; CHECK-NEXT:    rldic 3, 3, 0, 16
; CHECK-NEXT:    blr
entry:
  ret i64 281474976710575

}

; Function Attrs: nounwind readnone
define i64 @f2(i64 %x) #0 {
; CHECK-LABEL: f2:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -1
; CHECK-NEXT:    rldic 3, 3, 36, 0
; CHECK-NEXT:    blr
entry:
  ret i64 -68719476736

}

; Function Attrs: nounwind readnone
define i64 @f2a(i64 %x) #0 {
; CHECK-LABEL: f2a:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -337
; CHECK-NEXT:    rldic 3, 3, 30, 0
; CHECK-NEXT:    blr
entry:
  ret i64 -361850994688

}

; Function Attrs: nounwind readnone
define i64 @f2n(i64 %x) #0 {
; CHECK-LABEL: f2n:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -1
; CHECK-NEXT:    rldic 3, 3, 0, 28
; CHECK-NEXT:    blr
entry:
  ret i64 68719476735

}

; Function Attrs: nounwind readnone
define i64 @f3(i64 %x) #0 {
; CHECK-LABEL: f3:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -1
; CHECK-NEXT:    rldic 3, 3, 0, 31
; CHECK-NEXT:    blr
entry:
  ret i64 8589934591

}

; Function Attrs: nounwind readnone
define i64 @cn2n() #0 {
; CHECK-LABEL: cn2n:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -5121
; CHECK-NEXT:    ori 3, 3, 65534
; CHECK-NEXT:    rotldi 3, 3, 22
; CHECK-NEXT:    blr
entry:
  ret i64 -1407374887747585

}

define i64 @uint32_1() #0 {
; CHECK-LABEL: uint32_1:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 18176
; CHECK-NEXT:    oris 3, 3, 59509
; CHECK-NEXT:    blr
entry:
  ret i64 3900000000

}

define i32 @uint32_1_i32() #0 {
; CHECK-LABEL: uint32_1_i32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 18176
; CHECK-NEXT:    oris 3, 3, 59509
; CHECK-NEXT:    blr
entry:
  ret i32 -394967296

}

define i64 @uint32_2() #0 {
; CHECK-LABEL: uint32_2:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -1
; CHECK-NEXT:    rldic 3, 3, 0, 32
; CHECK-NEXT:    blr
entry:
  ret i64 4294967295

}

define i32 @uint32_2_i32() #0 {
; CHECK-LABEL: uint32_2_i32:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -1
; CHECK-NEXT:    rldic 3, 3, 0, 32
; CHECK-NEXT:    blr
entry:
  ret i32 -1

}

define i64 @uint32_3() #0 {
; CHECK-LABEL: uint32_3:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 1
; CHECK-NEXT:    rldic 3, 3, 31, 32
; CHECK-NEXT:    blr
entry:
  ret i64 2147483648

}

define i64 @uint32_4() #0 {
; CHECK-LABEL: uint32_4:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -6027
; CHECK-NEXT:    ori 3, 3, 18177
; CHECK-NEXT:    rldic 3, 3, 5, 27
; CHECK-NEXT:    blr
entry:
  ret i64 124800000032

}

define i64 @cn_ones_1() #0 {
; CHECK-LABEL: cn_ones_1:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -25633
; CHECK-NEXT:    rldicl 3, 3, 18, 30
; CHECK-NEXT:    blr
entry:
  ret i64 10460594175

}

define i64 @cn_ones_2() #0 {
; CHECK-LABEL: cn_ones_2:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -25638
; CHECK-NEXT:    ori 3, 3, 24575
; CHECK-NEXT:    rldicl 3, 3, 2, 30
; CHECK-NEXT:    blr
entry:
  ret i64 10459119615

}

define i64 @imm1() #0 {
; CHECK-LABEL: imm1:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 8465
; CHECK-NEXT:    rldic 3, 3, 28, 22
; CHECK-NEXT:    blr
entry:
  ret i64 2272306135040 ;0x21110000000
}

define i64 @imm2() #0 {
; CHECK-LABEL: imm2:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -28536
; CHECK-NEXT:    rldicl 3, 3, 1, 32
; CHECK-NEXT:    blr
entry:
  ret i64 4294910225 ;0xFFFF2111
}

define i64 @imm3() #0 {
; CHECK-LABEL: imm3:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -32495
; CHECK-NEXT:    rldic 3, 3, 0, 32
; CHECK-NEXT:    blr
entry:
  ret i64 4294934801 ;0xFFFF8111
}

define i64 @imm4() #0 {
; CHECK-LABEL: imm4:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, 33
; CHECK-NEXT:    ori 3, 3, 4352
; CHECK-NEXT:    rldimi 3, 3, 32, 0
; CHECK-NEXT:    blr
entry:
  ret i64 9307365931290880 ;0x21110000211100
}

define i64 @imm5() #0 {
; CHECK-LABEL: imm5:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 28685
; CHECK-NEXT:    rotldi 3, 3, 52
; CHECK-NEXT:    blr
entry:
  ret i64 58546795155816455 ;0xd0000000000007
}

define i64 @imm6() #0 {
; CHECK-LABEL: imm6:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -1
; CHECK-NEXT:    ori 3, 3, 28674
; CHECK-NEXT:    rotldi 3, 3, 52
; CHECK-NEXT:    blr
entry:
  ret i64 13510798882111479 ;0x2ffffffffffff7
}

define i64 @imm7() #0 {
; CHECK-LABEL: imm7:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -3823
; CHECK-NEXT:    rldic 3, 3, 28, 20
; CHECK-NEXT:    blr
entry:
  ret i64 16565957296128 ;0xf1110000000
}

define i64 @imm8() #0 {
; CHECK-LABEL: imm8:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -7919
; CHECK-NEXT:    rldic 3, 3, 22, 22
; CHECK-NEXT:    blr
entry:
  ret i64 4364831817728 ;0x3f844400000
}

define i64 @imm9() #0 {
; CHECK-LABEL: imm9:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -1
; CHECK-NEXT:    ori 3, 3, 28674
; CHECK-NEXT:    rotldi 3, 3, 52
; CHECK-NEXT:    blr
entry:
  ret i64 13510798882111479 ;0x2ffffffffffff7
}

define i64 @imm10() #0 {
; CHECK-LABEL: imm10:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -3823
; CHECK-NEXT:    rldic 3, 3, 28, 20
; CHECK-NEXT:    blr
entry:
  ret i64 16565957296128 ;0xf1110000000
}

define i64 @imm11() #0 {
; CHECK-LABEL: imm11:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -7919
; CHECK-NEXT:    rldic 3, 3, 22, 22
; CHECK-NEXT:    blr
entry:
  ret i64 4364831817728 ;0x3f844400000
}

define i64 @imm12() #0 {
; CHECK-LABEL: imm12:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -29
; CHECK-NEXT:    ori 3, 3, 64577
; CHECK-NEXT:    rldic 3, 3, 12, 20
; CHECK-NEXT:    blr
entry:
  ret i64 17584665923584 ;0xffe3fc41000
}

define i64 @imm13() #0 {
; CHECK-LABEL: imm13:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -24847
; CHECK-NEXT:    rldicl 3, 3, 21, 27
; CHECK-NEXT:    blr
entry:
  ret i64 85333114879 ;0x13de3fffff
}

define i64 @imm13_2() #0 {
; CHECK-LABEL: imm13_2:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -12424
; CHECK-NEXT:    rldicl 3, 3, 22, 26
; CHECK-NEXT:    blr
entry:
  ret i64 222772068351 ;0x33de3fffff
}

define i64 @imm14() #0 {
; CHECK-LABEL: imm14:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -3960
; CHECK-NEXT:    rldicl 3, 3, 21, 24
; CHECK-NEXT:    blr
entry:
  ret i64 1091209003007 ;0xfe111fffff
}

define i64 @imm15() #0 {
; CHECK-LABEL: imm15:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, -8065
; CHECK-NEXT:    rldic 3, 3, 24, 0
; CHECK-NEXT:    blr
entry:
  ret i64 -135308247040
}

define i64 @imm16() #0 {
; CHECK-LABEL: imm16:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -16392
; CHECK-NEXT:    ori 3, 3, 57217
; CHECK-NEXT:    rldic 3, 3, 16, 0
; CHECK-NEXT:    blr
entry:
  ret i64 -70399354142720
}

define i64 @imm17() #0 {
; CHECK-LABEL: imm17:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, 20344
; CHECK-NEXT:    ori 3, 3, 32847
; CHECK-NEXT:    rotldi 3, 3, 49
; CHECK-NEXT:    blr
entry:
  ret i64 44473046320324337 ;0x9e000000009ef1
}

define i64 @imm18() #0 {
; CHECK-LABEL: imm18:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 1
; CHECK-NEXT:    rldic 3, 3, 33, 30
; CHECK-NEXT:    oris 3, 3, 39436
; CHECK-NEXT:    ori 3, 3, 61633
; CHECK-NEXT:    blr
entry:
  ret i64 11174473921
}

define i64 @imm19() {
; CHECK-LABEL: imm19:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -13105
; CHECK-NEXT:    ori 3, 3, 52479
; CHECK-NEXT:    rldic 3, 3, 32, 0
; CHECK-NEXT:    oris 3, 3, 52431
; CHECK-NEXT:    ori 3, 3, 291
; CHECK-NEXT:    blr
entry:
  ret i64 14758239902941249827 ;0xCCCFCCFFCCCF0123
}

define i64 @imm20() {
; CHECK-LABEL: imm20:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, 291
; CHECK-NEXT:    ori 3, 3, 52479
; CHECK-NEXT:    rldimi 3, 3, 32, 0
; CHECK-NEXT:    rldimi 3, 3, 48, 0
; CHECK-NEXT:    blr
entry:
  ret i64 14771750698406366463 ;0xCCFFCCFF0123CCFF
}

define i64 @imm21() {
; CHECK-LABEL: imm21:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -13057
; CHECK-NEXT:    ori 3, 3, 291
; CHECK-NEXT:    rldimi 3, 3, 32, 0
; CHECK-NEXT:    rlwimi 3, 3, 16, 16, 31
; CHECK-NEXT:    blr
entry:
  ret i64 14771526556073315583 ;0xCCFF0123CCFFCCFF
}

define i64 @imm22() {
; CHECK-LABEL: imm22:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, 291
; CHECK-NEXT:    ori 3, 3, 52479
; CHECK-NEXT:    rldimi 3, 3, 32, 0
; CHECK-NEXT:    rlwimi 3, 3, 16, 0, 15
; CHECK-NEXT:    blr
entry:
  ret i64 82134617250843903 ;0x0123CCFFCCFFCCFF
}

define i64 @imm23() {
; CHECK-LABEL: imm23:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    li 3, 32767
; CHECK-NEXT:    rldimi 3, 3, 32, 0
; CHECK-NEXT:    blr
entry:
  ret i64 140733193420799 ;0x00007FFF00007FFF
}

define i64 @imm24() {
; CHECK-LABEL: imm24:
; CHECK:       # %bb.0: # %entry
; CHECK-NEXT:    lis 3, -9
; CHECK-NEXT:    rldimi 3, 3, 32, 0
; CHECK-NEXT:    blr
entry:
  ret i64 18444210803213533184 ;0xFFF70000FFF70000
}

attributes #0 = { nounwind readnone }
