Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -verify-coalescing | FileCheck %s
      3 
      4 define i32* @test1(i32* %P, i32 %X) {
      5 ; CHECK-LABEL: test1:
      6 ; CHECK:       # %bb.0:
      7 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
      8 ; CHECK-NEXT:    andl $-4, %eax
      9 ; CHECK-NEXT:    addl {{[0-9]+}}(%esp), %eax
     10 ; CHECK-NEXT:    retl
     11   %Y = lshr i32 %X, 2
     12   %gep.upgrd.1 = zext i32 %Y to i64
     13   %P2 = getelementptr i32, i32* %P, i64 %gep.upgrd.1
     14   ret i32* %P2
     15 }
     16 
     17 define i32* @test2(i32* %P, i32 %X) {
     18 ; CHECK-LABEL: test2:
     19 ; CHECK:       # %bb.0:
     20 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
     21 ; CHECK-NEXT:    shll $4, %eax
     22 ; CHECK-NEXT:    addl {{[0-9]+}}(%esp), %eax
     23 ; CHECK-NEXT:    retl
     24   %Y = shl i32 %X, 2
     25   %gep.upgrd.2 = zext i32 %Y to i64
     26   %P2 = getelementptr i32, i32* %P, i64 %gep.upgrd.2
     27   ret i32* %P2
     28 }
     29 
     30 define i32* @test3(i32* %P, i32 %X) {
     31 ; CHECK-LABEL: test3:
     32 ; CHECK:       # %bb.0:
     33 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %eax
     34 ; CHECK-NEXT:    andl $-4, %eax
     35 ; CHECK-NEXT:    addl {{[0-9]+}}(%esp), %eax
     36 ; CHECK-NEXT:    retl
     37   %Y = ashr i32 %X, 2
     38   %P2 = getelementptr i32, i32* %P, i32 %Y
     39   ret i32* %P2
     40 }
     41 
     42 define fastcc i32 @test4(i32* %d) {
     43 ; CHECK-LABEL: test4:
     44 ; CHECK:       # %bb.0:
     45 ; CHECK-NEXT:    movzbl 3(%ecx), %eax
     46 ; CHECK-NEXT:    retl
     47   %tmp4 = load i32, i32* %d
     48   %tmp512 = lshr i32 %tmp4, 24
     49   ret i32 %tmp512
     50 }
     51 
     52 ; Ensure that we don't fold away shifts which have multiple uses, as they are
     53 ; just re-introduced for the second use.
     54 
     55 define i64 @test5(i16 %i, i32* %arr) {
     56 ; CHECK-LABEL: test5:
     57 ; CHECK:       # %bb.0:
     58 ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %ecx
     59 ; CHECK-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
     60 ; CHECK-NEXT:    shrl $11, %eax
     61 ; CHECK-NEXT:    xorl %edx, %edx
     62 ; CHECK-NEXT:    addl (%ecx,%eax,4), %eax
     63 ; CHECK-NEXT:    setb %dl
     64 ; CHECK-NEXT:    retl
     65   %i.zext = zext i16 %i to i32
     66   %index = lshr i32 %i.zext, 11
     67   %index.zext = zext i32 %index to i64
     68   %val.ptr = getelementptr inbounds i32, i32* %arr, i64 %index.zext
     69   %val = load i32, i32* %val.ptr
     70   %val.zext = zext i32 %val to i64
     71   %sum = add i64 %val.zext, %index.zext
     72   ret i64 %sum
     73 }
     74