Home | History | Annotate | Download | only in llvm2ice_tests
      1 ; This is a very early test that just checks the representation of i32
      2 ; arithmetic instructions.  No assembly tests are done.
      3 
      4 ; REQUIRES: allow_dump
      5 
      6 ; RUN: %p2i -i %s --filetype=asm --args --verbose inst -threads=0 \
      7 ; RUN:   -allow-externally-defined-symbols | FileCheck %s
      8 
      9 define internal i32 @Add(i32 %a, i32 %b) {
     10 ; CHECK: define internal i32 @Add
     11 entry:
     12   %add = add i32 %b, %a
     13 ; CHECK: add
     14   tail call void @Use(i32 %add)
     15 ; CHECK: call Use
     16   ret i32 %add
     17 }
     18 
     19 declare void @Use(i32)
     20 
     21 define internal i32 @And(i32 %a, i32 %b) {
     22 ; CHECK: define internal i32 @And
     23 entry:
     24   %and = and i32 %b, %a
     25 ; CHECK: and
     26   tail call void @Use(i32 %and)
     27 ; CHECK: call Use
     28   ret i32 %and
     29 }
     30 
     31 define internal i32 @Or(i32 %a, i32 %b) {
     32 ; CHECK: define internal i32 @Or
     33 entry:
     34   %or = or i32 %b, %a
     35 ; CHECK: or
     36   tail call void @Use(i32 %or)
     37 ; CHECK: call Use
     38   ret i32 %or
     39 }
     40 
     41 define internal i32 @Xor(i32 %a, i32 %b) {
     42 ; CHECK: define internal i32 @Xor
     43 entry:
     44   %xor = xor i32 %b, %a
     45 ; CHECK: xor
     46   tail call void @Use(i32 %xor)
     47 ; CHECK: call Use
     48   ret i32 %xor
     49 }
     50 
     51 define internal i32 @Sub(i32 %a, i32 %b) {
     52 ; CHECK: define internal i32 @Sub
     53 entry:
     54   %sub = sub i32 %a, %b
     55 ; CHECK: sub
     56   tail call void @Use(i32 %sub)
     57 ; CHECK: call Use
     58   ret i32 %sub
     59 }
     60 
     61 define internal i32 @Mul(i32 %a, i32 %b) {
     62 ; CHECK: define internal i32 @Mul
     63 entry:
     64   %mul = mul i32 %b, %a
     65 ; CHECK: imul
     66   tail call void @Use(i32 %mul)
     67 ; CHECK: call Use
     68   ret i32 %mul
     69 }
     70 
     71 define internal i32 @Sdiv(i32 %a, i32 %b) {
     72 ; CHECK: define internal i32 @Sdiv
     73 entry:
     74   %div = sdiv i32 %a, %b
     75 ; CHECK: cdq
     76 ; CHECK: idiv
     77   tail call void @Use(i32 %div)
     78 ; CHECK: call Use
     79   ret i32 %div
     80 }
     81 
     82 define internal i32 @Srem(i32 %a, i32 %b) {
     83 ; CHECK: define internal i32 @Srem
     84 entry:
     85   %rem = srem i32 %a, %b
     86 ; CHECK: cdq
     87 ; CHECK: idiv
     88   tail call void @Use(i32 %rem)
     89 ; CHECK: call Use
     90   ret i32 %rem
     91 }
     92 
     93 define internal i32 @Udiv(i32 %a, i32 %b) {
     94 ; CHECK: define internal i32 @Udiv
     95 entry:
     96   %div = udiv i32 %a, %b
     97 ; CHECK: div
     98   tail call void @Use(i32 %div)
     99 ; CHECK: call Use
    100   ret i32 %div
    101 }
    102 
    103 define internal i32 @Urem(i32 %a, i32 %b) {
    104 ; CHECK: define internal i32 @Urem
    105 entry:
    106   %rem = urem i32 %a, %b
    107 ; CHECK: div
    108   tail call void @Use(i32 %rem)
    109 ; CHECK: call Use
    110   ret i32 %rem
    111 }
    112 
    113 ; Check for a valid addressing mode in the x86-32 mul instruction when
    114 ; the second source operand is an immediate.
    115 define internal i64 @MulImm() {
    116 entry:
    117   %mul = mul i64 3, 4
    118   ret i64 %mul
    119 }
    120 ; CHECK-LABEL: MulImm
    121 ; CHECK-NOT: mul {{[0-9]+}}
    122