Home | History | Annotate | Download | only in llvm2ice_tests
      1 ; This checks the correctness of the lowering code for the small
      2 ; integer variants of sdiv and srem.
      3 
      4 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -O2 | FileCheck %s
      5 ; RUN: %p2i -i %s --filetype=obj --disassemble --args -Om1 | FileCheck %s
      6 
      7 ; RUN: %if --need=target_MIPS32 --need=allow_dump \
      8 ; RUN:   --command %p2i --filetype=asm --assemble --disassemble --target \
      9 ; RUN:   mips32 -i %s --args -O2 -allow-externally-defined-symbols \
     10 ; RUN:   | %if --need=target_MIPS32 --need=allow_dump \
     11 ; RUN:   --command FileCheck --check-prefix MIPS32 %s
     12 
     13 define internal i32 @sdiv_i8(i32 %a.i32, i32 %b.i32) {
     14 entry:
     15   %a = trunc i32 %a.i32 to i8
     16   %b = trunc i32 %b.i32 to i8
     17   %res = sdiv i8 %a, %b
     18   %res.i32 = zext i8 %res to i32
     19   ret i32 %res.i32
     20 ; CHECK-LABEL: sdiv_i8
     21 ; CHECK: cbw
     22 ; CHECK: idiv
     23 ; MIPS32-LABEL: sdiv_i8
     24 ; MIPS32: 	div
     25 ; MIPS32: 	teq
     26 ; MIPS32: 	mflo
     27 ; MIPS32: 	andi	{{.*}},0xff
     28 }
     29 
     30 define internal i32 @sdiv_i16(i32 %a.i32, i32 %b.i32) {
     31 entry:
     32   %a = trunc i32 %a.i32 to i16
     33   %b = trunc i32 %b.i32 to i16
     34   %res = sdiv i16 %a, %b
     35   %res.i32 = zext i16 %res to i32
     36   ret i32 %res.i32
     37 ; CHECK-LABEL: sdiv_i16
     38 ; CHECK: cwd
     39 ; CHECK: idiv
     40 ; MIPS32-LABEL: sdiv_i16
     41 ; MIPS32: 	div
     42 ; MIPS32: 	teq
     43 ; MIPS32: 	mflo
     44 ; MIPS32: 	andi	{{.*}},0xffff
     45 }
     46 
     47 define internal i32 @sdiv_i32(i32 %a, i32 %b) {
     48 entry:
     49   %res = sdiv i32 %a, %b
     50   ret i32 %res
     51 ; CHECK-LABEL: sdiv_i32
     52 ; CHECK: cdq
     53 ; CHECK: idiv
     54 ; MIPS32-LABEL: sdiv_i32
     55 ; MIPS32: 	div
     56 ; MIPS32: 	teq
     57 ; MIPS32: 	mflo
     58 }
     59 
     60 define internal i32 @srem_i8(i32 %a.i32, i32 %b.i32) {
     61 entry:
     62   %a = trunc i32 %a.i32 to i8
     63   %b = trunc i32 %b.i32 to i8
     64   %res = srem i8 %a, %b
     65   %res.i32 = zext i8 %res to i32
     66   ret i32 %res.i32
     67 ; CHECK-LABEL: srem_i8
     68 ; CHECK: cbw
     69 ; CHECK: idiv
     70 ; MIPS32-LABEL: srem_i8
     71 ; MIPS32: 	div
     72 ; MIPS32: 	teq
     73 ; MIPS32: 	mfhi
     74 ; MIPS32: 	andi	{{.*}},0xff
     75 }
     76 
     77 define internal i32 @srem_i16(i32 %a.i32, i32 %b.i32) {
     78 entry:
     79   %a = trunc i32 %a.i32 to i16
     80   %b = trunc i32 %b.i32 to i16
     81   %res = srem i16 %a, %b
     82   %res.i32 = zext i16 %res to i32
     83   ret i32 %res.i32
     84 ; CHECK-LABEL: srem_i16
     85 ; CHECK: cwd
     86 ; CHECK: idiv
     87 ; MIPS32-LABEL: srem_i16
     88 ; MIPS32: 	div
     89 ; MIPS32: 	teq
     90 ; MIPS32: 	mfhi
     91 ; MIPS32: 	andi	{{.*}},0xffff
     92 }
     93 
     94 define internal i32 @srem_i32(i32 %a, i32 %b) {
     95 entry:
     96   %res = srem i32 %a, %b
     97   ret i32 %res
     98 ; CHECK-LABEL: srem_i32
     99 ; CHECK: cdq
    100 ; CHECK: idiv
    101 ; MIPS32-LABEL: srem_i32
    102 ; MIPS32: 	div
    103 ; MIPS32: 	teq
    104 ; MIPS32: 	mfhi
    105 }
    106