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