1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -O2 \ 3; RUN: -ppc-gpr-icmps=all -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-BE \ 4; RUN: --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl 5; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O2 \ 6; RUN: -ppc-gpr-icmps=all -ppc-asm-full-reg-names -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-LE \ 7; RUN: --implicit-check-not cmpw --implicit-check-not cmpd --implicit-check-not cmpl 8 9@glob = dso_local local_unnamed_addr global i32 0, align 4 10 11define dso_local signext i32 @test_inesi(i32 signext %a, i32 signext %b) { 12; CHECK-LABEL: test_inesi: 13; CHECK: # %bb.0: # %entry 14; CHECK-NEXT: xor r3, r3, r4 15; CHECK-NEXT: cntlzw r3, r3 16; CHECK-NEXT: srwi r3, r3, 5 17; CHECK-NEXT: xori r3, r3, 1 18; CHECK-NEXT: blr 19; CHECK-BE-LABEL: test_inesi: 20; CHECK-BE: # %bb.0: # %entry 21; CHECK-BE-NEXT: xor r3, r3, r4 22; CHECK-BE-NEXT: cntlzw r3, r3 23; CHECK-BE-NEXT: srwi r3, r3, 5 24; CHECK-BE-NEXT: xori r3, r3, 1 25; CHECK-BE-NEXT: blr 26; 27; CHECK-LE-LABEL: test_inesi: 28; CHECK-LE: # %bb.0: # %entry 29; CHECK-LE-NEXT: xor r3, r3, r4 30; CHECK-LE-NEXT: cntlzw r3, r3 31; CHECK-LE-NEXT: srwi r3, r3, 5 32; CHECK-LE-NEXT: xori r3, r3, 1 33; CHECK-LE-NEXT: blr 34entry: 35 %cmp = icmp ne i32 %a, %b 36 %conv = zext i1 %cmp to i32 37 ret i32 %conv 38} 39 40define dso_local signext i32 @test_inesi_sext(i32 signext %a, i32 signext %b) { 41; CHECK-LABEL: test_inesi_sext: 42; CHECK: # %bb.0: # %entry 43; CHECK-NEXT: xor r3, r3, r4 44; CHECK-NEXT: cntlzw r3, r3 45; CHECK-NEXT: srwi r3, r3, 5 46; CHECK-NEXT: xori r3, r3, 1 47; CHECK-NEXT: neg r3, r3 48; CHECK-NEXT: blr 49; CHECK-BE-LABEL: test_inesi_sext: 50; CHECK-BE: # %bb.0: # %entry 51; CHECK-BE-NEXT: xor r3, r3, r4 52; CHECK-BE-NEXT: cntlzw r3, r3 53; CHECK-BE-NEXT: srwi r3, r3, 5 54; CHECK-BE-NEXT: xori r3, r3, 1 55; CHECK-BE-NEXT: neg r3, r3 56; CHECK-BE-NEXT: blr 57; 58; CHECK-LE-LABEL: test_inesi_sext: 59; CHECK-LE: # %bb.0: # %entry 60; CHECK-LE-NEXT: xor r3, r3, r4 61; CHECK-LE-NEXT: cntlzw r3, r3 62; CHECK-LE-NEXT: srwi r3, r3, 5 63; CHECK-LE-NEXT: xori r3, r3, 1 64; CHECK-LE-NEXT: neg r3, r3 65; CHECK-LE-NEXT: blr 66entry: 67 %cmp = icmp ne i32 %a, %b 68 %sub = sext i1 %cmp to i32 69 ret i32 %sub 70} 71 72define dso_local signext i32 @test_inesi_z(i32 signext %a) { 73; CHECK-LABEL: test_inesi_z: 74; CHECK: # %bb.0: # %entry 75; CHECK-NEXT: cntlzw r3, r3 76; CHECK-NEXT: srwi r3, r3, 5 77; CHECK-NEXT: xori r3, r3, 1 78; CHECK-NEXT: blr 79; CHECK-BE-LABEL: test_inesi_z: 80; CHECK-BE: # %bb.0: # %entry 81; CHECK-BE-NEXT: cntlzw r3, r3 82; CHECK-BE-NEXT: srwi r3, r3, 5 83; CHECK-BE-NEXT: xori r3, r3, 1 84; CHECK-BE-NEXT: blr 85; 86; CHECK-LE-LABEL: test_inesi_z: 87; CHECK-LE: # %bb.0: # %entry 88; CHECK-LE-NEXT: cntlzw r3, r3 89; CHECK-LE-NEXT: srwi r3, r3, 5 90; CHECK-LE-NEXT: xori r3, r3, 1 91; CHECK-LE-NEXT: blr 92entry: 93 %cmp = icmp ne i32 %a, 0 94 %conv = zext i1 %cmp to i32 95 ret i32 %conv 96} 97 98define dso_local signext i32 @test_inesi_sext_z(i32 signext %a) { 99; CHECK-LABEL: test_inesi_sext_z: 100; CHECK: # %bb.0: # %entry 101; CHECK-NEXT: cntlzw r3, r3 102; CHECK-NEXT: srwi r3, r3, 5 103; CHECK-NEXT: xori r3, r3, 1 104; CHECK-NEXT: neg r3, r3 105; CHECK-NEXT: blr 106; CHECK-BE-LABEL: test_inesi_sext_z: 107; CHECK-BE: # %bb.0: # %entry 108; CHECK-BE-NEXT: cntlzw r3, r3 109; CHECK-BE-NEXT: srwi r3, r3, 5 110; CHECK-BE-NEXT: xori r3, r3, 1 111; CHECK-BE-NEXT: neg r3, r3 112; CHECK-BE-NEXT: blr 113; 114; CHECK-LE-LABEL: test_inesi_sext_z: 115; CHECK-LE: # %bb.0: # %entry 116; CHECK-LE-NEXT: cntlzw r3, r3 117; CHECK-LE-NEXT: srwi r3, r3, 5 118; CHECK-LE-NEXT: xori r3, r3, 1 119; CHECK-LE-NEXT: neg r3, r3 120; CHECK-LE-NEXT: blr 121entry: 122 %cmp = icmp ne i32 %a, 0 123 %sub = sext i1 %cmp to i32 124 ret i32 %sub 125} 126 127define dso_local void @test_inesi_store(i32 signext %a, i32 signext %b) { 128; CHECK-LABEL: test_inesi_store: 129; CHECK: # %bb.0: # %entry 130; CHECK-NEXT: xor r3, r3, r4 131; CHECK-NEXT: addis r5, r2, glob@toc@ha 132; CHECK-NEXT: cntlzw r3, r3 133; CHECK-NEXT: srwi r3, r3, 5 134; CHECK-NEXT: xori r3, r3, 1 135; CHECK-NEXT: stw r3, glob@toc@l(r5) 136; CHECK-NEXT: blr 137; CHECK-BE-LABEL: test_inesi_store: 138; CHECK-BE: # %bb.0: # %entry 139; CHECK-BE-NEXT: xor r3, r3, r4 140; CHECK-BE-NEXT: addis r5, r2, glob@toc@ha 141; CHECK-BE-NEXT: cntlzw r3, r3 142; CHECK-BE-NEXT: srwi r3, r3, 5 143; CHECK-BE-NEXT: xori r3, r3, 1 144; CHECK-BE-NEXT: stw r3, glob@toc@l(r5) 145; CHECK-BE-NEXT: blr 146; 147; CHECK-LE-LABEL: test_inesi_store: 148; CHECK-LE: # %bb.0: # %entry 149; CHECK-LE-NEXT: xor r3, r3, r4 150; CHECK-LE-NEXT: addis r5, r2, glob@toc@ha 151; CHECK-LE-NEXT: cntlzw r3, r3 152; CHECK-LE-NEXT: srwi r3, r3, 5 153; CHECK-LE-NEXT: xori r3, r3, 1 154; CHECK-LE-NEXT: stw r3, glob@toc@l(r5) 155; CHECK-LE-NEXT: blr 156entry: 157 %cmp = icmp ne i32 %a, %b 158 %conv = zext i1 %cmp to i32 159 store i32 %conv, i32* @glob, align 4 160 ret void 161} 162 163define dso_local void @test_inesi_sext_store(i32 signext %a, i32 signext %b) { 164; CHECK-LABEL: test_inesi_sext_store: 165; CHECK: # %bb.0: # %entry 166; CHECK-NEXT: xor r3, r3, r4 167; CHECK-NEXT: addis r5, r2, glob@toc@ha 168; CHECK-NEXT: cntlzw r3, r3 169; CHECK-NEXT: srwi r3, r3, 5 170; CHECK-NEXT: xori r3, r3, 1 171; CHECK-NEXT: neg r3, r3 172; CHECK-NEXT: stw r3, glob@toc@l(r5) 173; CHECK-NEXT: blr 174; CHECK-BE-LABEL: test_inesi_sext_store: 175; CHECK-BE: # %bb.0: # %entry 176; CHECK-BE-NEXT: xor r3, r3, r4 177; CHECK-BE-NEXT: addis r5, r2, glob@toc@ha 178; CHECK-BE-NEXT: cntlzw r3, r3 179; CHECK-BE-NEXT: srwi r3, r3, 5 180; CHECK-BE-NEXT: xori r3, r3, 1 181; CHECK-BE-NEXT: neg r3, r3 182; CHECK-BE-NEXT: stw r3, glob@toc@l(r5) 183; CHECK-BE-NEXT: blr 184; 185; CHECK-LE-LABEL: test_inesi_sext_store: 186; CHECK-LE: # %bb.0: # %entry 187; CHECK-LE-NEXT: xor r3, r3, r4 188; CHECK-LE-NEXT: addis r5, r2, glob@toc@ha 189; CHECK-LE-NEXT: cntlzw r3, r3 190; CHECK-LE-NEXT: srwi r3, r3, 5 191; CHECK-LE-NEXT: xori r3, r3, 1 192; CHECK-LE-NEXT: neg r3, r3 193; CHECK-LE-NEXT: stw r3, glob@toc@l(r5) 194; CHECK-LE-NEXT: blr 195entry: 196 %cmp = icmp ne i32 %a, %b 197 %sub = sext i1 %cmp to i32 198 store i32 %sub, i32* @glob, align 4 199 ret void 200} 201 202define dso_local void @test_inesi_z_store(i32 signext %a) { 203; CHECK-LABEL: test_inesi_z_store: 204; CHECK: # %bb.0: # %entry 205; CHECK-NEXT: cntlzw r3, r3 206; CHECK-NEXT: addis r4, r2, glob@toc@ha 207; CHECK-NEXT: srwi r3, r3, 5 208; CHECK-NEXT: xori r3, r3, 1 209; CHECK-NEXT: stw r3, glob@toc@l(r4) 210; CHECK-NEXT: blr 211; CHECK-BE-LABEL: test_inesi_z_store: 212; CHECK-BE: # %bb.0: # %entry 213; CHECK-BE-NEXT: cntlzw r3, r3 214; CHECK-BE-NEXT: addis r4, r2, glob@toc@ha 215; CHECK-BE-NEXT: srwi r3, r3, 5 216; CHECK-BE-NEXT: xori r3, r3, 1 217; CHECK-BE-NEXT: stw r3, glob@toc@l(r4) 218; CHECK-BE-NEXT: blr 219; 220; CHECK-LE-LABEL: test_inesi_z_store: 221; CHECK-LE: # %bb.0: # %entry 222; CHECK-LE-NEXT: cntlzw r3, r3 223; CHECK-LE-NEXT: addis r4, r2, glob@toc@ha 224; CHECK-LE-NEXT: srwi r3, r3, 5 225; CHECK-LE-NEXT: xori r3, r3, 1 226; CHECK-LE-NEXT: stw r3, glob@toc@l(r4) 227; CHECK-LE-NEXT: blr 228entry: 229 %cmp = icmp ne i32 %a, 0 230 %conv = zext i1 %cmp to i32 231 store i32 %conv, i32* @glob, align 4 232 ret void 233} 234 235define dso_local void @test_inesi_sext_z_store(i32 signext %a) { 236; CHECK-LABEL: test_inesi_sext_z_store: 237; CHECK: # %bb.0: # %entry 238; CHECK-NEXT: cntlzw r3, r3 239; CHECK-NEXT: addis r4, r2, glob@toc@ha 240; CHECK-NEXT: srwi r3, r3, 5 241; CHECK-NEXT: xori r3, r3, 1 242; CHECK-NEXT: neg r3, r3 243; CHECK-NEXT: stw r3, glob@toc@l(r4) 244; CHECK-NEXT: blr 245; CHECK-BE-LABEL: test_inesi_sext_z_store: 246; CHECK-BE: # %bb.0: # %entry 247; CHECK-BE-NEXT: cntlzw r3, r3 248; CHECK-BE-NEXT: addis r4, r2, glob@toc@ha 249; CHECK-BE-NEXT: srwi r3, r3, 5 250; CHECK-BE-NEXT: xori r3, r3, 1 251; CHECK-BE-NEXT: neg r3, r3 252; CHECK-BE-NEXT: stw r3, glob@toc@l(r4) 253; CHECK-BE-NEXT: blr 254; 255; CHECK-LE-LABEL: test_inesi_sext_z_store: 256; CHECK-LE: # %bb.0: # %entry 257; CHECK-LE-NEXT: cntlzw r3, r3 258; CHECK-LE-NEXT: addis r4, r2, glob@toc@ha 259; CHECK-LE-NEXT: srwi r3, r3, 5 260; CHECK-LE-NEXT: xori r3, r3, 1 261; CHECK-LE-NEXT: neg r3, r3 262; CHECK-LE-NEXT: stw r3, glob@toc@l(r4) 263; CHECK-LE-NEXT: blr 264entry: 265 %cmp = icmp ne i32 %a, 0 266 %sub = sext i1 %cmp to i32 267 store i32 %sub, i32* @glob, align 4 268 ret void 269} 270