1*f4a2713aSLionel Sambuc; RUN: llc < %s -march=x86 -mcpu=corei7 | FileCheck %s 2*f4a2713aSLionel Sambuc; RUN: llc < %s -march=x86 -mcpu=core-avx2 | FileCheck %s --check-prefix=BMI2 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambucdefine i32 @foo(i32 %x, i32 %y, i32 %z) nounwind readnone { 5*f4a2713aSLionel Sambucentry: 6*f4a2713aSLionel Sambuc; CHECK-LABEL: foo: 7*f4a2713aSLionel Sambuc; CHECK: roll %cl 8*f4a2713aSLionel Sambuc %0 = shl i32 %x, %z 9*f4a2713aSLionel Sambuc %1 = sub i32 32, %z 10*f4a2713aSLionel Sambuc %2 = lshr i32 %x, %1 11*f4a2713aSLionel Sambuc %3 = or i32 %2, %0 12*f4a2713aSLionel Sambuc ret i32 %3 13*f4a2713aSLionel Sambuc} 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambucdefine i32 @bar(i32 %x, i32 %y, i32 %z) nounwind readnone { 16*f4a2713aSLionel Sambucentry: 17*f4a2713aSLionel Sambuc; CHECK-LABEL: bar: 18*f4a2713aSLionel Sambuc; CHECK: shldl %cl 19*f4a2713aSLionel Sambuc %0 = shl i32 %y, %z 20*f4a2713aSLionel Sambuc %1 = sub i32 32, %z 21*f4a2713aSLionel Sambuc %2 = lshr i32 %x, %1 22*f4a2713aSLionel Sambuc %3 = or i32 %2, %0 23*f4a2713aSLionel Sambuc ret i32 %3 24*f4a2713aSLionel Sambuc} 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambucdefine i32 @un(i32 %x, i32 %y, i32 %z) nounwind readnone { 27*f4a2713aSLionel Sambucentry: 28*f4a2713aSLionel Sambuc; CHECK-LABEL: un: 29*f4a2713aSLionel Sambuc; CHECK: rorl %cl 30*f4a2713aSLionel Sambuc %0 = lshr i32 %x, %z 31*f4a2713aSLionel Sambuc %1 = sub i32 32, %z 32*f4a2713aSLionel Sambuc %2 = shl i32 %x, %1 33*f4a2713aSLionel Sambuc %3 = or i32 %2, %0 34*f4a2713aSLionel Sambuc ret i32 %3 35*f4a2713aSLionel Sambuc} 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambucdefine i32 @bu(i32 %x, i32 %y, i32 %z) nounwind readnone { 38*f4a2713aSLionel Sambucentry: 39*f4a2713aSLionel Sambuc; CHECK-LABEL: bu: 40*f4a2713aSLionel Sambuc; CHECK: shrdl %cl 41*f4a2713aSLionel Sambuc %0 = lshr i32 %y, %z 42*f4a2713aSLionel Sambuc %1 = sub i32 32, %z 43*f4a2713aSLionel Sambuc %2 = shl i32 %x, %1 44*f4a2713aSLionel Sambuc %3 = or i32 %2, %0 45*f4a2713aSLionel Sambuc ret i32 %3 46*f4a2713aSLionel Sambuc} 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambucdefine i32 @xfoo(i32 %x, i32 %y, i32 %z) nounwind readnone { 49*f4a2713aSLionel Sambucentry: 50*f4a2713aSLionel Sambuc; CHECK-LABEL: xfoo: 51*f4a2713aSLionel Sambuc; CHECK: roll $7 52*f4a2713aSLionel Sambuc; BMI2-LABEL: xfoo: 53*f4a2713aSLionel Sambuc; BMI2: rorxl $25 54*f4a2713aSLionel Sambuc %0 = lshr i32 %x, 25 55*f4a2713aSLionel Sambuc %1 = shl i32 %x, 7 56*f4a2713aSLionel Sambuc %2 = or i32 %0, %1 57*f4a2713aSLionel Sambuc ret i32 %2 58*f4a2713aSLionel Sambuc} 59*f4a2713aSLionel Sambuc 60*f4a2713aSLionel Sambucdefine i32 @xfoop(i32* %p) nounwind readnone { 61*f4a2713aSLionel Sambucentry: 62*f4a2713aSLionel Sambuc; BMI2-LABEL: xfoop: 63*f4a2713aSLionel Sambuc; BMI2: rorxl $25, ({{.+}}), %{{.+}} 64*f4a2713aSLionel Sambuc %x = load i32* %p 65*f4a2713aSLionel Sambuc %a = lshr i32 %x, 25 66*f4a2713aSLionel Sambuc %b = shl i32 %x, 7 67*f4a2713aSLionel Sambuc %c = or i32 %a, %b 68*f4a2713aSLionel Sambuc ret i32 %c 69*f4a2713aSLionel Sambuc} 70*f4a2713aSLionel Sambuc 71*f4a2713aSLionel Sambucdefine i32 @xbar(i32 %x, i32 %y, i32 %z) nounwind readnone { 72*f4a2713aSLionel Sambucentry: 73*f4a2713aSLionel Sambuc; CHECK-LABEL: xbar: 74*f4a2713aSLionel Sambuc; CHECK: shldl $7 75*f4a2713aSLionel Sambuc %0 = shl i32 %y, 7 76*f4a2713aSLionel Sambuc %1 = lshr i32 %x, 25 77*f4a2713aSLionel Sambuc %2 = or i32 %0, %1 78*f4a2713aSLionel Sambuc ret i32 %2 79*f4a2713aSLionel Sambuc} 80*f4a2713aSLionel Sambuc 81*f4a2713aSLionel Sambucdefine i32 @xun(i32 %x, i32 %y, i32 %z) nounwind readnone { 82*f4a2713aSLionel Sambucentry: 83*f4a2713aSLionel Sambuc; CHECK-LABEL: xun: 84*f4a2713aSLionel Sambuc; CHECK: roll $25 85*f4a2713aSLionel Sambuc; BMI2-LABEL: xun: 86*f4a2713aSLionel Sambuc; BMI2: rorxl $7 87*f4a2713aSLionel Sambuc %0 = lshr i32 %x, 7 88*f4a2713aSLionel Sambuc %1 = shl i32 %x, 25 89*f4a2713aSLionel Sambuc %2 = or i32 %0, %1 90*f4a2713aSLionel Sambuc ret i32 %2 91*f4a2713aSLionel Sambuc} 92*f4a2713aSLionel Sambuc 93*f4a2713aSLionel Sambucdefine i32 @xunp(i32* %p) nounwind readnone { 94*f4a2713aSLionel Sambucentry: 95*f4a2713aSLionel Sambuc; BMI2-LABEL: xunp: 96*f4a2713aSLionel Sambuc; BMI2: rorxl $7, ({{.+}}), %{{.+}} 97*f4a2713aSLionel Sambuc %x = load i32* %p 98*f4a2713aSLionel Sambuc %a = lshr i32 %x, 7 99*f4a2713aSLionel Sambuc %b = shl i32 %x, 25 100*f4a2713aSLionel Sambuc %c = or i32 %a, %b 101*f4a2713aSLionel Sambuc ret i32 %c 102*f4a2713aSLionel Sambuc} 103*f4a2713aSLionel Sambuc 104*f4a2713aSLionel Sambucdefine i32 @xbu(i32 %x, i32 %y, i32 %z) nounwind readnone { 105*f4a2713aSLionel Sambucentry: 106*f4a2713aSLionel Sambuc; CHECK-LABEL: xbu: 107*f4a2713aSLionel Sambuc; CHECK: shldl 108*f4a2713aSLionel Sambuc %0 = lshr i32 %y, 7 109*f4a2713aSLionel Sambuc %1 = shl i32 %x, 25 110*f4a2713aSLionel Sambuc %2 = or i32 %0, %1 111*f4a2713aSLionel Sambuc ret i32 %2 112*f4a2713aSLionel Sambuc} 113