1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=i686-unknown-linux-gnu < %s | FileCheck %s --check-prefix=X86 3; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s --check-prefix=X64 4 5define i1 @t32_3_1(i32 %X) nounwind { 6; X86-LABEL: t32_3_1: 7; X86: # %bb.0: 8; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 9; X86-NEXT: addl $1431655765, %eax # imm = 0x55555555 10; X86-NEXT: cmpl $1431655765, %eax # imm = 0x55555555 11; X86-NEXT: setb %al 12; X86-NEXT: retl 13; 14; X64-LABEL: t32_3_1: 15; X64: # %bb.0: 16; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 17; X64-NEXT: addl $1431655765, %eax # imm = 0x55555555 18; X64-NEXT: cmpl $1431655765, %eax # imm = 0x55555555 19; X64-NEXT: setb %al 20; X64-NEXT: retq 21 %urem = urem i32 %X, 3 22 %cmp = icmp eq i32 %urem, 1 23 ret i1 %cmp 24} 25 26define i1 @t32_3_2(i32 %X) nounwind { 27; X86-LABEL: t32_3_2: 28; X86: # %bb.0: 29; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 30; X86-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA 31; X86-NEXT: cmpl $1431655765, %eax # imm = 0x55555555 32; X86-NEXT: setb %al 33; X86-NEXT: retl 34; 35; X64-LABEL: t32_3_2: 36; X64: # %bb.0: 37; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 38; X64-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA 39; X64-NEXT: cmpl $1431655765, %eax # imm = 0x55555555 40; X64-NEXT: setb %al 41; X64-NEXT: retq 42 %urem = urem i32 %X, 3 43 %cmp = icmp eq i32 %urem, 2 44 ret i1 %cmp 45} 46 47 48define i1 @t32_5_1(i32 %X) nounwind { 49; X86-LABEL: t32_5_1: 50; X86: # %bb.0: 51; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD 52; X86-NEXT: addl $858993459, %eax # imm = 0x33333333 53; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333 54; X86-NEXT: setb %al 55; X86-NEXT: retl 56; 57; X64-LABEL: t32_5_1: 58; X64: # %bb.0: 59; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD 60; X64-NEXT: addl $858993459, %eax # imm = 0x33333333 61; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333 62; X64-NEXT: setb %al 63; X64-NEXT: retq 64 %urem = urem i32 %X, 5 65 %cmp = icmp eq i32 %urem, 1 66 ret i1 %cmp 67} 68 69define i1 @t32_5_2(i32 %X) nounwind { 70; X86-LABEL: t32_5_2: 71; X86: # %bb.0: 72; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD 73; X86-NEXT: addl $1717986918, %eax # imm = 0x66666666 74; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333 75; X86-NEXT: setb %al 76; X86-NEXT: retl 77; 78; X64-LABEL: t32_5_2: 79; X64: # %bb.0: 80; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD 81; X64-NEXT: addl $1717986918, %eax # imm = 0x66666666 82; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333 83; X64-NEXT: setb %al 84; X64-NEXT: retq 85 %urem = urem i32 %X, 5 86 %cmp = icmp eq i32 %urem, 2 87 ret i1 %cmp 88} 89 90define i1 @t32_5_3(i32 %X) nounwind { 91; X86-LABEL: t32_5_3: 92; X86: # %bb.0: 93; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD 94; X86-NEXT: addl $-1717986919, %eax # imm = 0x99999999 95; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333 96; X86-NEXT: setb %al 97; X86-NEXT: retl 98; 99; X64-LABEL: t32_5_3: 100; X64: # %bb.0: 101; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD 102; X64-NEXT: addl $-1717986919, %eax # imm = 0x99999999 103; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333 104; X64-NEXT: setb %al 105; X64-NEXT: retq 106 %urem = urem i32 %X, 5 107 %cmp = icmp eq i32 %urem, 3 108 ret i1 %cmp 109} 110 111define i1 @t32_5_4(i32 %X) nounwind { 112; X86-LABEL: t32_5_4: 113; X86: # %bb.0: 114; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD 115; X86-NEXT: addl $-858993460, %eax # imm = 0xCCCCCCCC 116; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333 117; X86-NEXT: setb %al 118; X86-NEXT: retl 119; 120; X64-LABEL: t32_5_4: 121; X64: # %bb.0: 122; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD 123; X64-NEXT: addl $-858993460, %eax # imm = 0xCCCCCCCC 124; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333 125; X64-NEXT: setb %al 126; X64-NEXT: retq 127 %urem = urem i32 %X, 5 128 %cmp = icmp eq i32 %urem, 4 129 ret i1 %cmp 130} 131 132 133define i1 @t32_6_1(i32 %X) nounwind { 134; X86-LABEL: t32_6_1: 135; X86: # %bb.0: 136; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 137; X86-NEXT: addl $1431655765, %eax # imm = 0x55555555 138; X86-NEXT: rorl %eax 139; X86-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB 140; X86-NEXT: setb %al 141; X86-NEXT: retl 142; 143; X64-LABEL: t32_6_1: 144; X64: # %bb.0: 145; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 146; X64-NEXT: addl $1431655765, %eax # imm = 0x55555555 147; X64-NEXT: rorl %eax 148; X64-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB 149; X64-NEXT: setb %al 150; X64-NEXT: retq 151 %urem = urem i32 %X, 6 152 %cmp = icmp eq i32 %urem, 1 153 ret i1 %cmp 154} 155 156define i1 @t32_6_2(i32 %X) nounwind { 157; X86-LABEL: t32_6_2: 158; X86: # %bb.0: 159; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 160; X86-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA 161; X86-NEXT: rorl %eax 162; X86-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB 163; X86-NEXT: setb %al 164; X86-NEXT: retl 165; 166; X64-LABEL: t32_6_2: 167; X64: # %bb.0: 168; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 169; X64-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA 170; X64-NEXT: rorl %eax 171; X64-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB 172; X64-NEXT: setb %al 173; X64-NEXT: retq 174 %urem = urem i32 %X, 6 175 %cmp = icmp eq i32 %urem, 2 176 ret i1 %cmp 177} 178 179define i1 @t32_6_3(i32 %X) nounwind { 180; X86-LABEL: t32_6_3: 181; X86: # %bb.0: 182; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 183; X86-NEXT: decl %eax 184; X86-NEXT: rorl %eax 185; X86-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB 186; X86-NEXT: setb %al 187; X86-NEXT: retl 188; 189; X64-LABEL: t32_6_3: 190; X64: # %bb.0: 191; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 192; X64-NEXT: decl %eax 193; X64-NEXT: rorl %eax 194; X64-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB 195; X64-NEXT: setb %al 196; X64-NEXT: retq 197 %urem = urem i32 %X, 6 198 %cmp = icmp eq i32 %urem, 3 199 ret i1 %cmp 200} 201 202define i1 @t32_6_4(i32 %X) nounwind { 203; X86-LABEL: t32_6_4: 204; X86: # %bb.0: 205; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 206; X86-NEXT: addl $1431655764, %eax # imm = 0x55555554 207; X86-NEXT: rorl %eax 208; X86-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA 209; X86-NEXT: setb %al 210; X86-NEXT: retl 211; 212; X64-LABEL: t32_6_4: 213; X64: # %bb.0: 214; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 215; X64-NEXT: addl $1431655764, %eax # imm = 0x55555554 216; X64-NEXT: rorl %eax 217; X64-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA 218; X64-NEXT: setb %al 219; X64-NEXT: retq 220 %urem = urem i32 %X, 6 221 %cmp = icmp eq i32 %urem, 4 222 ret i1 %cmp 223} 224 225define i1 @t32_6_5(i32 %X) nounwind { 226; X86-LABEL: t32_6_5: 227; X86: # %bb.0: 228; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB 229; X86-NEXT: addl $-1431655767, %eax # imm = 0xAAAAAAA9 230; X86-NEXT: rorl %eax 231; X86-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA 232; X86-NEXT: setb %al 233; X86-NEXT: retl 234; 235; X64-LABEL: t32_6_5: 236; X64: # %bb.0: 237; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB 238; X64-NEXT: addl $-1431655767, %eax # imm = 0xAAAAAAA9 239; X64-NEXT: rorl %eax 240; X64-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA 241; X64-NEXT: setb %al 242; X64-NEXT: retq 243 %urem = urem i32 %X, 6 244 %cmp = icmp eq i32 %urem, 5 245 ret i1 %cmp 246} 247 248;------------------------------------------------------------------------------- 249; Other widths. 250 251define i1 @t16_3_2(i16 %X) nounwind { 252; X86-LABEL: t16_3_2: 253; X86: # %bb.0: 254; X86-NEXT: imull $-21845, {{[0-9]+}}(%esp), %eax # imm = 0xAAAB 255; X86-NEXT: addl $-21846, %eax # imm = 0xAAAA 256; X86-NEXT: movzwl %ax, %eax 257; X86-NEXT: cmpl $21845, %eax # imm = 0x5555 258; X86-NEXT: setb %al 259; X86-NEXT: retl 260; 261; X64-LABEL: t16_3_2: 262; X64: # %bb.0: 263; X64-NEXT: imull $-21845, %edi, %eax # imm = 0xAAAB 264; X64-NEXT: addl $-21846, %eax # imm = 0xAAAA 265; X64-NEXT: movzwl %ax, %eax 266; X64-NEXT: cmpl $21845, %eax # imm = 0x5555 267; X64-NEXT: setb %al 268; X64-NEXT: retq 269 %urem = urem i16 %X, 3 270 %cmp = icmp eq i16 %urem, 2 271 ret i1 %cmp 272} 273 274define i1 @t8_3_2(i8 %X) nounwind { 275; X86-LABEL: t8_3_2: 276; X86: # %bb.0: 277; X86-NEXT: imull $-85, {{[0-9]+}}(%esp), %eax 278; X86-NEXT: addb $-86, %al 279; X86-NEXT: cmpb $85, %al 280; X86-NEXT: setb %al 281; X86-NEXT: retl 282; 283; X64-LABEL: t8_3_2: 284; X64: # %bb.0: 285; X64-NEXT: imull $-85, %edi, %eax 286; X64-NEXT: addb $-86, %al 287; X64-NEXT: cmpb $85, %al 288; X64-NEXT: setb %al 289; X64-NEXT: retq 290 %urem = urem i8 %X, 3 291 %cmp = icmp eq i8 %urem, 2 292 ret i1 %cmp 293} 294 295define i1 @t64_3_2(i64 %X) nounwind { 296; X86-LABEL: t64_3_2: 297; X86: # %bb.0: 298; X86-NEXT: subl $12, %esp 299; X86-NEXT: pushl $0 300; X86-NEXT: pushl $3 301; X86-NEXT: pushl {{[0-9]+}}(%esp) 302; X86-NEXT: pushl {{[0-9]+}}(%esp) 303; X86-NEXT: calll __umoddi3 304; X86-NEXT: addl $16, %esp 305; X86-NEXT: xorl $2, %eax 306; X86-NEXT: orl %edx, %eax 307; X86-NEXT: sete %al 308; X86-NEXT: addl $12, %esp 309; X86-NEXT: retl 310; 311; X64-LABEL: t64_3_2: 312; X64: # %bb.0: 313; X64-NEXT: movabsq $-6148914691236517205, %rax # imm = 0xAAAAAAAAAAAAAAAB 314; X64-NEXT: imulq %rdi, %rax 315; X64-NEXT: movabsq $-6148914691236517206, %rcx # imm = 0xAAAAAAAAAAAAAAAA 316; X64-NEXT: addq %rax, %rcx 317; X64-NEXT: movabsq $6148914691236517205, %rax # imm = 0x5555555555555555 318; X64-NEXT: cmpq %rax, %rcx 319; X64-NEXT: setb %al 320; X64-NEXT: retq 321 %urem = urem i64 %X, 3 322 %cmp = icmp eq i64 %urem, 2 323 ret i1 %cmp 324} 325