2013-05-07 00:17:29 +08:00
|
|
|
; Test 32-bit ANDs in which the second operand is constant.
|
|
|
|
;
|
2013-07-31 19:36:35 +08:00
|
|
|
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z196 | FileCheck %s
|
2013-05-07 00:17:29 +08:00
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ANDs with 1 can use NILF.
|
2013-05-07 00:17:29 +08:00
|
|
|
define i32 @f1(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f1:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilf %r2, 1
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
|
|
|
%and = and i32 %a, 1
|
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...but RISBLG is available as a three-address form.
|
|
|
|
define i32 @f2(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f2:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 31, 159, 0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 1
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...same for 4.
|
|
|
|
define i32 @f3(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f3:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 29, 157, 0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 4
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ANDs with 5 must use NILF.
|
2013-05-07 00:17:29 +08:00
|
|
|
define i32 @f4(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f4:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilf %r2, 5
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, 5
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...a single RISBLG isn't enough.
|
|
|
|
define i32 @f5(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f5:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK-NOT: risb
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 5
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-11 16:59:12 +08:00
|
|
|
; Check the highest 16-bit constant that must be handled by NILF.
|
2013-05-07 00:17:29 +08:00
|
|
|
define i32 @f6(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f6:
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: nilf %r2, 65533
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-11 16:59:12 +08:00
|
|
|
%and = and i32 %a, 65533
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...a single RISBLG isn't enough.
|
|
|
|
define i32 @f7(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f7:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK-NOT: risb
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 65533
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the next highest value, which can use NILF.
|
2013-05-07 00:17:29 +08:00
|
|
|
define i32 @f8(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f8:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilf %r2, 65534
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, 65534
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...although the three-address case should use RISBLG.
|
|
|
|
define i32 @f9(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f9:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 16, 158, 0
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 65534
|
2013-05-07 00:17:29 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ANDs of 0xffff are zero extensions from i16.
|
|
|
|
define i32 @f10(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f10:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: llhr %r2, %r3
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 65535
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the next value up, which must again use NILF.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f11(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f11:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilf %r2, 65536
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, 65536
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...but the three-address case can use RISBLG.
|
|
|
|
define i32 @f12(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f12:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 15, 143, 0
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 65536
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the lowest useful NILH value.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f13(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f13:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilh %r2, 1
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, 131071
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...but RISBLG is OK in the three-address case.
|
|
|
|
define i32 @f14(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f14:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 15, 159, 0
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, 131071
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the highest useful NILF value.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f15(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f15:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilf %r2, 4294901758
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, -65538
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the next value up, which is the highest useful NILH value.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f16(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f16:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nilh %r2, 65534
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, -65537
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the next value up, which is the first useful NILL value.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f17(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f17:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nill %r2, 0
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, -65536
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...although the three-address case should use RISBLG.
|
|
|
|
define i32 @f18(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f18:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 0, 143, 0
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, -65536
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the next value up again, which can still use NILL.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f19(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f19:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nill %r2, 1
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
|
|
|
%and = and i32 %a, -65535
|
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the next value up again, which cannot use RISBLG.
|
|
|
|
define i32 @f20(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f20:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK-NOT: risb
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, -65534
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Check the last useful mask, which can use NILL.
|
2013-07-11 16:59:12 +08:00
|
|
|
define i32 @f21(i32 %a) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f21:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: nill %r2, 65534
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %a, -2
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...or RISBLG for the three-address case.
|
|
|
|
define i32 @f22(i32 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f22:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 0, 158, 0
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and = and i32 %b, -2
|
2013-07-11 16:59:12 +08:00
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; Test that RISBLG can be used when inserting a non-wraparound mask
|
|
|
|
; into another register.
|
|
|
|
define i64 @f23(i64 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f23:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 30, 158, 0
|
2013-07-11 16:59:12 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and1 = and i64 %a, -4294967296
|
|
|
|
%and2 = and i32 %b, 2
|
|
|
|
%ext = zext i32 %and2 to i64
|
|
|
|
%or = or i64 %and1, %ext
|
|
|
|
ret i64 %or
|
2013-07-11 16:59:12 +08:00
|
|
|
}
|
|
|
|
|
2013-07-31 19:36:35 +08:00
|
|
|
; ...and when inserting a wrap-around mask.
|
|
|
|
define i64 @f24(i64 %a, i32 %b) {
|
2013-07-14 14:24:09 +08:00
|
|
|
; CHECK-LABEL: f24:
|
2013-07-31 19:36:35 +08:00
|
|
|
; CHECK: risblg %r2, %r3, 30, 156
|
2013-05-07 00:17:29 +08:00
|
|
|
; CHECK: br %r14
|
2013-07-31 19:36:35 +08:00
|
|
|
%and1 = and i64 %a, -4294967296
|
|
|
|
%and2 = and i32 %b, -5
|
|
|
|
%ext = zext i32 %and2 to i64
|
|
|
|
%or = or i64 %and1, %ext
|
|
|
|
ret i64 %or
|
2013-05-07 00:17:29 +08:00
|
|
|
}
|