1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=armv6-none-eabi %s -o - | FileCheck %s --check-prefixes=CHECK-ARM,CHECK-ARMV6 3; RUN: llc -mtriple=armv7a-none-eabi %s -o - | FileCheck %s --check-prefixes=CHECK-ARM,CHECK-ARMV7 4; RUN: llc -mtriple=thumbv6m-none-eabi %s -o - | FileCheck %s --check-prefixes=CHECK-THUMB,CHECK-THUMBV6M 5; RUN: llc -mtriple=thumbv7m-none-eabi %s -o - | FileCheck %s --check-prefixes=CHECK-THUMB,CHECK-THUMBV7M 6 7define i32 @fold_add19_mul11_i32(i32 %a) { 8; CHECK-ARM-LABEL: fold_add19_mul11_i32: 9; CHECK-ARM: @ %bb.0: 10; CHECK-ARM-NEXT: mov r1, #11 11; CHECK-ARM-NEXT: mul r0, r0, r1 12; CHECK-ARM-NEXT: add r0, r0, #209 13; CHECK-ARM-NEXT: bx lr 14; 15; CHECK-THUMB-LABEL: fold_add19_mul11_i32: 16; CHECK-THUMB: @ %bb.0: 17; CHECK-THUMB-NEXT: movs r1, #11 18; CHECK-THUMB-NEXT: muls r0, r1, r0 19; CHECK-THUMB-NEXT: adds r0, #209 20; CHECK-THUMB-NEXT: bx lr 21 %b = add i32 %a, 19 22 %c = mul i32 %b, 11 23 ret i32 %c 24} 25 26define i16 @fold_add19_mul11_i16(i16 %a) { 27; CHECK-ARM-LABEL: fold_add19_mul11_i16: 28; CHECK-ARM: @ %bb.0: 29; CHECK-ARM-NEXT: mov r1, #11 30; CHECK-ARM-NEXT: mul r0, r0, r1 31; CHECK-ARM-NEXT: add r0, r0, #209 32; CHECK-ARM-NEXT: bx lr 33; 34; CHECK-THUMB-LABEL: fold_add19_mul11_i16: 35; CHECK-THUMB: @ %bb.0: 36; CHECK-THUMB-NEXT: movs r1, #11 37; CHECK-THUMB-NEXT: muls r0, r1, r0 38; CHECK-THUMB-NEXT: adds r0, #209 39; CHECK-THUMB-NEXT: bx lr 40 %b = add i16 %a, 19 41 %c = mul i16 %b, 11 42 ret i16 %c 43} 44 45define i32 @fold_sub19_mul11_i32(i32 %a) { 46; CHECK-ARM-LABEL: fold_sub19_mul11_i32: 47; CHECK-ARM: @ %bb.0: 48; CHECK-ARM-NEXT: mov r1, #11 49; CHECK-ARM-NEXT: mul r0, r0, r1 50; CHECK-ARM-NEXT: sub r0, r0, #209 51; CHECK-ARM-NEXT: bx lr 52; 53; CHECK-THUMB-LABEL: fold_sub19_mul11_i32: 54; CHECK-THUMB: @ %bb.0: 55; CHECK-THUMB-NEXT: movs r1, #11 56; CHECK-THUMB-NEXT: muls r0, r1, r0 57; CHECK-THUMB-NEXT: subs r0, #209 58; CHECK-THUMB-NEXT: bx lr 59 %b = add i32 %a, -19 60 %c = mul i32 %b, 11 61 ret i32 %c 62} 63 64define i16 @fold_sub19_mul11_i16(i16 %a) { 65; CHECK-ARM-LABEL: fold_sub19_mul11_i16: 66; CHECK-ARM: @ %bb.0: 67; CHECK-ARM-NEXT: mov r1, #11 68; CHECK-ARM-NEXT: mul r0, r0, r1 69; CHECK-ARM-NEXT: sub r0, r0, #209 70; CHECK-ARM-NEXT: bx lr 71; 72; CHECK-THUMB-LABEL: fold_sub19_mul11_i16: 73; CHECK-THUMB: @ %bb.0: 74; CHECK-THUMB-NEXT: movs r1, #11 75; CHECK-THUMB-NEXT: muls r0, r1, r0 76; CHECK-THUMB-NEXT: subs r0, #209 77; CHECK-THUMB-NEXT: bx lr 78 %b = add i16 %a, -19 79 %c = mul i16 %b, 11 80 ret i16 %c 81} 82 83define i32 @fold_add301_mul19_i32(i32 %a) { 84; CHECK-ARMV6-LABEL: fold_add301_mul19_i32: 85; CHECK-ARMV6: @ %bb.0: 86; CHECK-ARMV6-NEXT: mov r1, #87 87; CHECK-ARMV6-NEXT: mov r2, #19 88; CHECK-ARMV6-NEXT: orr r1, r1, #5632 89; CHECK-ARMV6-NEXT: mla r0, r0, r2, r1 90; CHECK-ARMV6-NEXT: bx lr 91; 92; CHECK-ARMV7-LABEL: fold_add301_mul19_i32: 93; CHECK-ARMV7: @ %bb.0: 94; CHECK-ARMV7-NEXT: movw r1, #5719 95; CHECK-ARMV7-NEXT: mov r2, #19 96; CHECK-ARMV7-NEXT: mla r0, r0, r2, r1 97; CHECK-ARMV7-NEXT: bx lr 98; 99; CHECK-THUMBV6M-LABEL: fold_add301_mul19_i32: 100; CHECK-THUMBV6M: @ %bb.0: 101; CHECK-THUMBV6M-NEXT: movs r1, #19 102; CHECK-THUMBV6M-NEXT: muls r1, r0, r1 103; CHECK-THUMBV6M-NEXT: ldr r0, .LCPI4_0 104; CHECK-THUMBV6M-NEXT: adds r0, r1, r0 105; CHECK-THUMBV6M-NEXT: bx lr 106; CHECK-THUMBV6M-NEXT: .p2align 2 107; CHECK-THUMBV6M-NEXT: @ %bb.1: 108; CHECK-THUMBV6M-NEXT: .LCPI4_0: 109; CHECK-THUMBV6M-NEXT: .long 5719 @ 0x1657 110; 111; CHECK-THUMBV7M-LABEL: fold_add301_mul19_i32: 112; CHECK-THUMBV7M: @ %bb.0: 113; CHECK-THUMBV7M-NEXT: movw r1, #5719 114; CHECK-THUMBV7M-NEXT: movs r2, #19 115; CHECK-THUMBV7M-NEXT: mla r0, r0, r2, r1 116; CHECK-THUMBV7M-NEXT: bx lr 117 %b = add i32 %a, 301 118 %c = mul i32 %b, 19 119 ret i32 %c 120} 121 122define i16 @fold_add301_mul19_i16(i16 %a) { 123; CHECK-ARMV6-LABEL: fold_add301_mul19_i16: 124; CHECK-ARMV6: @ %bb.0: 125; CHECK-ARMV6-NEXT: mov r1, #87 126; CHECK-ARMV6-NEXT: mov r2, #19 127; CHECK-ARMV6-NEXT: orr r1, r1, #5632 128; CHECK-ARMV6-NEXT: mla r0, r0, r2, r1 129; CHECK-ARMV6-NEXT: bx lr 130; 131; CHECK-ARMV7-LABEL: fold_add301_mul19_i16: 132; CHECK-ARMV7: @ %bb.0: 133; CHECK-ARMV7-NEXT: movw r1, #5719 134; CHECK-ARMV7-NEXT: mov r2, #19 135; CHECK-ARMV7-NEXT: mla r0, r0, r2, r1 136; CHECK-ARMV7-NEXT: bx lr 137; 138; CHECK-THUMBV6M-LABEL: fold_add301_mul19_i16: 139; CHECK-THUMBV6M: @ %bb.0: 140; CHECK-THUMBV6M-NEXT: movs r1, #19 141; CHECK-THUMBV6M-NEXT: muls r1, r0, r1 142; CHECK-THUMBV6M-NEXT: ldr r0, .LCPI5_0 143; CHECK-THUMBV6M-NEXT: adds r0, r1, r0 144; CHECK-THUMBV6M-NEXT: bx lr 145; CHECK-THUMBV6M-NEXT: .p2align 2 146; CHECK-THUMBV6M-NEXT: @ %bb.1: 147; CHECK-THUMBV6M-NEXT: .LCPI5_0: 148; CHECK-THUMBV6M-NEXT: .long 5719 @ 0x1657 149; 150; CHECK-THUMBV7M-LABEL: fold_add301_mul19_i16: 151; CHECK-THUMBV7M: @ %bb.0: 152; CHECK-THUMBV7M-NEXT: movw r1, #5719 153; CHECK-THUMBV7M-NEXT: movs r2, #19 154; CHECK-THUMBV7M-NEXT: mla r0, r0, r2, r1 155; CHECK-THUMBV7M-NEXT: bx lr 156 %b = add i16 %a, 301 157 %c = mul i16 %b, 19 158 ret i16 %c 159} 160 161define i32 @fold_sub301_mul19_i32(i32 %a) { 162; CHECK-ARMV6-LABEL: fold_sub301_mul19_i32: 163; CHECK-ARMV6: @ %bb.0: 164; CHECK-ARMV6-NEXT: mvn r1, #86 165; CHECK-ARMV6-NEXT: mov r2, #19 166; CHECK-ARMV6-NEXT: sub r1, r1, #5632 167; CHECK-ARMV6-NEXT: mla r0, r0, r2, r1 168; CHECK-ARMV6-NEXT: bx lr 169; 170; CHECK-ARMV7-LABEL: fold_sub301_mul19_i32: 171; CHECK-ARMV7: @ %bb.0: 172; CHECK-ARMV7-NEXT: mov r1, #19 173; CHECK-ARMV7-NEXT: mul r0, r0, r1 174; CHECK-ARMV7-NEXT: movw r1, #5719 175; CHECK-ARMV7-NEXT: sub r0, r0, r1 176; CHECK-ARMV7-NEXT: bx lr 177; 178; CHECK-THUMBV6M-LABEL: fold_sub301_mul19_i32: 179; CHECK-THUMBV6M: @ %bb.0: 180; CHECK-THUMBV6M-NEXT: movs r1, #19 181; CHECK-THUMBV6M-NEXT: muls r1, r0, r1 182; CHECK-THUMBV6M-NEXT: ldr r0, .LCPI6_0 183; CHECK-THUMBV6M-NEXT: adds r0, r1, r0 184; CHECK-THUMBV6M-NEXT: bx lr 185; CHECK-THUMBV6M-NEXT: .p2align 2 186; CHECK-THUMBV6M-NEXT: @ %bb.1: 187; CHECK-THUMBV6M-NEXT: .LCPI6_0: 188; CHECK-THUMBV6M-NEXT: .long 4294961577 @ 0xffffe9a9 189; 190; CHECK-THUMBV7M-LABEL: fold_sub301_mul19_i32: 191; CHECK-THUMBV7M: @ %bb.0: 192; CHECK-THUMBV7M-NEXT: movs r1, #19 193; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 194; CHECK-THUMBV7M-NEXT: movw r1, #5719 195; CHECK-THUMBV7M-NEXT: subs r0, r0, r1 196; CHECK-THUMBV7M-NEXT: bx lr 197 %b = add i32 %a, -301 198 %c = mul i32 %b, 19 199 ret i32 %c 200} 201 202define i16 @fold_sub301_mul19_i16(i16 %a) { 203; CHECK-ARMV6-LABEL: fold_sub301_mul19_i16: 204; CHECK-ARMV6: @ %bb.0: 205; CHECK-ARMV6-NEXT: mvn r1, #86 206; CHECK-ARMV6-NEXT: mov r2, #19 207; CHECK-ARMV6-NEXT: sub r1, r1, #5632 208; CHECK-ARMV6-NEXT: mla r0, r0, r2, r1 209; CHECK-ARMV6-NEXT: bx lr 210; 211; CHECK-ARMV7-LABEL: fold_sub301_mul19_i16: 212; CHECK-ARMV7: @ %bb.0: 213; CHECK-ARMV7-NEXT: mov r1, #19 214; CHECK-ARMV7-NEXT: mul r0, r0, r1 215; CHECK-ARMV7-NEXT: movw r1, #5719 216; CHECK-ARMV7-NEXT: sub r0, r0, r1 217; CHECK-ARMV7-NEXT: bx lr 218; 219; CHECK-THUMBV6M-LABEL: fold_sub301_mul19_i16: 220; CHECK-THUMBV6M: @ %bb.0: 221; CHECK-THUMBV6M-NEXT: movs r1, #19 222; CHECK-THUMBV6M-NEXT: muls r1, r0, r1 223; CHECK-THUMBV6M-NEXT: ldr r0, .LCPI7_0 224; CHECK-THUMBV6M-NEXT: adds r0, r1, r0 225; CHECK-THUMBV6M-NEXT: bx lr 226; CHECK-THUMBV6M-NEXT: .p2align 2 227; CHECK-THUMBV6M-NEXT: @ %bb.1: 228; CHECK-THUMBV6M-NEXT: .LCPI7_0: 229; CHECK-THUMBV6M-NEXT: .long 4294961577 @ 0xffffe9a9 230; 231; CHECK-THUMBV7M-LABEL: fold_sub301_mul19_i16: 232; CHECK-THUMBV7M: @ %bb.0: 233; CHECK-THUMBV7M-NEXT: movs r1, #19 234; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 235; CHECK-THUMBV7M-NEXT: movw r1, #5719 236; CHECK-THUMBV7M-NEXT: subs r0, r0, r1 237; CHECK-THUMBV7M-NEXT: bx lr 238 %b = add i16 %a, -301 239 %c = mul i16 %b, 19 240 ret i16 %c 241} 242 243define i32 @fold_add251_mul253_i32(i32 %a) { 244; CHECK-ARMV6-LABEL: fold_add251_mul253_i32: 245; CHECK-ARMV6: @ %bb.0: 246; CHECK-ARMV6-NEXT: add r0, r0, #251 247; CHECK-ARMV6-NEXT: mov r1, #253 248; CHECK-ARMV6-NEXT: mul r0, r0, r1 249; CHECK-ARMV6-NEXT: bx lr 250; 251; CHECK-ARMV7-LABEL: fold_add251_mul253_i32: 252; CHECK-ARMV7: @ %bb.0: 253; CHECK-ARMV7-NEXT: movw r1, #63503 254; CHECK-ARMV7-NEXT: mov r2, #253 255; CHECK-ARMV7-NEXT: mla r0, r0, r2, r1 256; CHECK-ARMV7-NEXT: bx lr 257; 258; CHECK-THUMBV6M-LABEL: fold_add251_mul253_i32: 259; CHECK-THUMBV6M: @ %bb.0: 260; CHECK-THUMBV6M-NEXT: adds r0, #251 261; CHECK-THUMBV6M-NEXT: movs r1, #253 262; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 263; CHECK-THUMBV6M-NEXT: bx lr 264; 265; CHECK-THUMBV7M-LABEL: fold_add251_mul253_i32: 266; CHECK-THUMBV7M: @ %bb.0: 267; CHECK-THUMBV7M-NEXT: movw r1, #63503 268; CHECK-THUMBV7M-NEXT: movs r2, #253 269; CHECK-THUMBV7M-NEXT: mla r0, r0, r2, r1 270; CHECK-THUMBV7M-NEXT: bx lr 271 %b = add i32 %a, 251 272 %c = mul i32 %b, 253 273 ret i32 %c 274} 275 276define i16 @fold_add251_mul253_i16(i16 %a) { 277; CHECK-ARMV6-LABEL: fold_add251_mul253_i16: 278; CHECK-ARMV6: @ %bb.0: 279; CHECK-ARMV6-NEXT: add r0, r0, #251 280; CHECK-ARMV6-NEXT: mov r1, #253 281; CHECK-ARMV6-NEXT: mul r0, r0, r1 282; CHECK-ARMV6-NEXT: bx lr 283; 284; CHECK-ARMV7-LABEL: fold_add251_mul253_i16: 285; CHECK-ARMV7: @ %bb.0: 286; CHECK-ARMV7-NEXT: mov r1, #253 287; CHECK-ARMV7-NEXT: mul r0, r0, r1 288; CHECK-ARMV7-NEXT: movw r1, #2033 289; CHECK-ARMV7-NEXT: sub r0, r0, r1 290; CHECK-ARMV7-NEXT: bx lr 291; 292; CHECK-THUMBV6M-LABEL: fold_add251_mul253_i16: 293; CHECK-THUMBV6M: @ %bb.0: 294; CHECK-THUMBV6M-NEXT: adds r0, #251 295; CHECK-THUMBV6M-NEXT: movs r1, #253 296; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 297; CHECK-THUMBV6M-NEXT: bx lr 298; 299; CHECK-THUMBV7M-LABEL: fold_add251_mul253_i16: 300; CHECK-THUMBV7M: @ %bb.0: 301; CHECK-THUMBV7M-NEXT: movs r1, #253 302; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 303; CHECK-THUMBV7M-NEXT: subw r0, r0, #2033 304; CHECK-THUMBV7M-NEXT: bx lr 305 %b = add i16 %a, 251 306 %c = mul i16 %b, 253 307 ret i16 %c 308} 309 310define i32 @fold_sub251_mul253_i32(i32 %a) { 311; CHECK-ARM-LABEL: fold_sub251_mul253_i32: 312; CHECK-ARM: @ %bb.0: 313; CHECK-ARM-NEXT: sub r0, r0, #251 314; CHECK-ARM-NEXT: mov r1, #253 315; CHECK-ARM-NEXT: mul r0, r0, r1 316; CHECK-ARM-NEXT: bx lr 317; 318; CHECK-THUMB-LABEL: fold_sub251_mul253_i32: 319; CHECK-THUMB: @ %bb.0: 320; CHECK-THUMB-NEXT: subs r0, #251 321; CHECK-THUMB-NEXT: movs r1, #253 322; CHECK-THUMB-NEXT: muls r0, r1, r0 323; CHECK-THUMB-NEXT: bx lr 324 %b = add i32 %a, -251 325 %c = mul i32 %b, 253 326 ret i32 %c 327} 328 329define i16 @fold_sub251_mul253_i16(i16 %a) { 330; CHECK-ARMV6-LABEL: fold_sub251_mul253_i16: 331; CHECK-ARMV6: @ %bb.0: 332; CHECK-ARMV6-NEXT: sub r0, r0, #251 333; CHECK-ARMV6-NEXT: mov r1, #253 334; CHECK-ARMV6-NEXT: mul r0, r0, r1 335; CHECK-ARMV6-NEXT: bx lr 336; 337; CHECK-ARMV7-LABEL: fold_sub251_mul253_i16: 338; CHECK-ARMV7: @ %bb.0: 339; CHECK-ARMV7-NEXT: movw r1, #2033 340; CHECK-ARMV7-NEXT: mov r2, #253 341; CHECK-ARMV7-NEXT: mla r0, r0, r2, r1 342; CHECK-ARMV7-NEXT: bx lr 343; 344; CHECK-THUMBV6M-LABEL: fold_sub251_mul253_i16: 345; CHECK-THUMBV6M: @ %bb.0: 346; CHECK-THUMBV6M-NEXT: subs r0, #251 347; CHECK-THUMBV6M-NEXT: movs r1, #253 348; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 349; CHECK-THUMBV6M-NEXT: bx lr 350; 351; CHECK-THUMBV7M-LABEL: fold_sub251_mul253_i16: 352; CHECK-THUMBV7M: @ %bb.0: 353; CHECK-THUMBV7M-NEXT: movs r1, #253 354; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 355; CHECK-THUMBV7M-NEXT: addw r0, r0, #2033 356; CHECK-THUMBV7M-NEXT: bx lr 357 %b = add i16 %a, -251 358 %c = mul i16 %b, 253 359 ret i16 %c 360} 361 362define i32 @fold_add251_mul353_i32(i32 %a) { 363; CHECK-ARMV6-LABEL: fold_add251_mul353_i32: 364; CHECK-ARMV6: @ %bb.0: 365; CHECK-ARMV6-NEXT: mov r1, #97 366; CHECK-ARMV6-NEXT: add r0, r0, #251 367; CHECK-ARMV6-NEXT: orr r1, r1, #256 368; CHECK-ARMV6-NEXT: mul r0, r0, r1 369; CHECK-ARMV6-NEXT: bx lr 370; 371; CHECK-ARMV7-LABEL: fold_add251_mul353_i32: 372; CHECK-ARMV7: @ %bb.0: 373; CHECK-ARMV7-NEXT: add r0, r0, #251 374; CHECK-ARMV7-NEXT: movw r1, #353 375; CHECK-ARMV7-NEXT: mul r0, r0, r1 376; CHECK-ARMV7-NEXT: bx lr 377; 378; CHECK-THUMBV6M-LABEL: fold_add251_mul353_i32: 379; CHECK-THUMBV6M: @ %bb.0: 380; CHECK-THUMBV6M-NEXT: movs r1, #255 381; CHECK-THUMBV6M-NEXT: adds r1, #98 382; CHECK-THUMBV6M-NEXT: adds r0, #251 383; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 384; CHECK-THUMBV6M-NEXT: bx lr 385; 386; CHECK-THUMBV7M-LABEL: fold_add251_mul353_i32: 387; CHECK-THUMBV7M: @ %bb.0: 388; CHECK-THUMBV7M-NEXT: adds r0, #251 389; CHECK-THUMBV7M-NEXT: movw r1, #353 390; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 391; CHECK-THUMBV7M-NEXT: bx lr 392 %b = add i32 %a, 251 393 %c = mul i32 %b, 353 394 ret i32 %c 395} 396 397define i16 @fold_add251_mul353_i16(i16 %a) { 398; CHECK-ARMV6-LABEL: fold_add251_mul353_i16: 399; CHECK-ARMV6: @ %bb.0: 400; CHECK-ARMV6-NEXT: mov r1, #97 401; CHECK-ARMV6-NEXT: add r0, r0, #251 402; CHECK-ARMV6-NEXT: orr r1, r1, #256 403; CHECK-ARMV6-NEXT: mul r0, r0, r1 404; CHECK-ARMV6-NEXT: bx lr 405; 406; CHECK-ARMV7-LABEL: fold_add251_mul353_i16: 407; CHECK-ARMV7: @ %bb.0: 408; CHECK-ARMV7-NEXT: movw r1, #23067 409; CHECK-ARMV7-NEXT: movw r2, #353 410; CHECK-ARMV7-NEXT: mla r0, r0, r2, r1 411; CHECK-ARMV7-NEXT: bx lr 412; 413; CHECK-THUMBV6M-LABEL: fold_add251_mul353_i16: 414; CHECK-THUMBV6M: @ %bb.0: 415; CHECK-THUMBV6M-NEXT: movs r1, #255 416; CHECK-THUMBV6M-NEXT: adds r1, #98 417; CHECK-THUMBV6M-NEXT: adds r0, #251 418; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 419; CHECK-THUMBV6M-NEXT: bx lr 420; 421; CHECK-THUMBV7M-LABEL: fold_add251_mul353_i16: 422; CHECK-THUMBV7M: @ %bb.0: 423; CHECK-THUMBV7M-NEXT: movw r1, #23067 424; CHECK-THUMBV7M-NEXT: movw r2, #353 425; CHECK-THUMBV7M-NEXT: mla r0, r0, r2, r1 426; CHECK-THUMBV7M-NEXT: bx lr 427 %b = add i16 %a, 251 428 %c = mul i16 %b, 353 429 ret i16 %c 430} 431 432define i32 @fold_sub251_mul353_i32(i32 %a) { 433; CHECK-ARMV6-LABEL: fold_sub251_mul353_i32: 434; CHECK-ARMV6: @ %bb.0: 435; CHECK-ARMV6-NEXT: mov r1, #97 436; CHECK-ARMV6-NEXT: sub r0, r0, #251 437; CHECK-ARMV6-NEXT: orr r1, r1, #256 438; CHECK-ARMV6-NEXT: mul r0, r0, r1 439; CHECK-ARMV6-NEXT: bx lr 440; 441; CHECK-ARMV7-LABEL: fold_sub251_mul353_i32: 442; CHECK-ARMV7: @ %bb.0: 443; CHECK-ARMV7-NEXT: sub r0, r0, #251 444; CHECK-ARMV7-NEXT: movw r1, #353 445; CHECK-ARMV7-NEXT: mul r0, r0, r1 446; CHECK-ARMV7-NEXT: bx lr 447; 448; CHECK-THUMBV6M-LABEL: fold_sub251_mul353_i32: 449; CHECK-THUMBV6M: @ %bb.0: 450; CHECK-THUMBV6M-NEXT: movs r1, #255 451; CHECK-THUMBV6M-NEXT: adds r1, #98 452; CHECK-THUMBV6M-NEXT: subs r0, #251 453; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 454; CHECK-THUMBV6M-NEXT: bx lr 455; 456; CHECK-THUMBV7M-LABEL: fold_sub251_mul353_i32: 457; CHECK-THUMBV7M: @ %bb.0: 458; CHECK-THUMBV7M-NEXT: subs r0, #251 459; CHECK-THUMBV7M-NEXT: movw r1, #353 460; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 461; CHECK-THUMBV7M-NEXT: bx lr 462 %b = add i32 %a, -251 463 %c = mul i32 %b, 353 464 ret i32 %c 465} 466 467define i16 @fold_sub251_mul353_i16(i16 %a) { 468; CHECK-ARMV6-LABEL: fold_sub251_mul353_i16: 469; CHECK-ARMV6: @ %bb.0: 470; CHECK-ARMV6-NEXT: mov r1, #97 471; CHECK-ARMV6-NEXT: sub r0, r0, #251 472; CHECK-ARMV6-NEXT: orr r1, r1, #256 473; CHECK-ARMV6-NEXT: mul r0, r0, r1 474; CHECK-ARMV6-NEXT: bx lr 475; 476; CHECK-ARMV7-LABEL: fold_sub251_mul353_i16: 477; CHECK-ARMV7: @ %bb.0: 478; CHECK-ARMV7-NEXT: movw r1, #353 479; CHECK-ARMV7-NEXT: mul r0, r0, r1 480; CHECK-ARMV7-NEXT: movw r1, #23067 481; CHECK-ARMV7-NEXT: sub r0, r0, r1 482; CHECK-ARMV7-NEXT: bx lr 483; 484; CHECK-THUMBV6M-LABEL: fold_sub251_mul353_i16: 485; CHECK-THUMBV6M: @ %bb.0: 486; CHECK-THUMBV6M-NEXT: movs r1, #255 487; CHECK-THUMBV6M-NEXT: adds r1, #98 488; CHECK-THUMBV6M-NEXT: subs r0, #251 489; CHECK-THUMBV6M-NEXT: muls r0, r1, r0 490; CHECK-THUMBV6M-NEXT: bx lr 491; 492; CHECK-THUMBV7M-LABEL: fold_sub251_mul353_i16: 493; CHECK-THUMBV7M: @ %bb.0: 494; CHECK-THUMBV7M-NEXT: movw r1, #353 495; CHECK-THUMBV7M-NEXT: muls r0, r1, r0 496; CHECK-THUMBV7M-NEXT: movw r1, #23067 497; CHECK-THUMBV7M-NEXT: subs r0, r0, r1 498; CHECK-THUMBV7M-NEXT: bx lr 499 %b = add i16 %a, -251 500 %c = mul i16 %b, 353 501 ret i16 %c 502} 503