231 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 42; RUN: llc -mtriple=x86_64-linux -mcpu=atom < %s | FileCheck %s3; RUN: llc -mtriple=x86_64-linux -mcpu=slm < %s | FileCheck %s -check-prefix=SLM4; RUN: llc -mtriple=x86_64-linux -mattr=+egpr,+ndd,+movbe --show-mc-encoding < %s | FileCheck %s -check-prefix=EGPR5; RUN: llc -mtriple=x86_64-linux -mattr=+egpr,+ndd --show-mc-encoding < %s | FileCheck %s -check-prefix=NOMOVBE6declare i16 @llvm.bswap.i16(i16) nounwind readnone7declare i32 @llvm.bswap.i32(i32) nounwind readnone8declare i64 @llvm.bswap.i64(i64) nounwind readnone9 10define void @test1(ptr nocapture %x, i16 %y) nounwind {11; CHECK-LABEL: test1:12; CHECK: # %bb.0:13; CHECK-NEXT: movbew %si, (%rdi)14; CHECK-NEXT: nop15; CHECK-NEXT: nop16; CHECK-NEXT: nop17; CHECK-NEXT: nop18; CHECK-NEXT: nop19; CHECK-NEXT: nop20; CHECK-NEXT: retq21;22; SLM-LABEL: test1:23; SLM: # %bb.0:24; SLM-NEXT: movbew %si, (%rdi)25; SLM-NEXT: retq26;27; EGPR-LABEL: test1:28; EGPR: # %bb.0:29; EGPR-NEXT: movbew %si, (%rdi) # EVEX TO LEGACY Compression encoding: [0x66,0x0f,0x38,0xf1,0x37]30; EGPR-NEXT: retq # encoding: [0xc3]31;32; NOMOVBE-LABEL: test1:33; NOMOVBE: # %bb.0:34; NOMOVBE-NEXT: rolw $8, %si, %ax # encoding: [0x62,0xf4,0x7d,0x18,0xc1,0xc6,0x08]35; NOMOVBE-NEXT: movw %ax, (%rdi) # encoding: [0x66,0x89,0x07]36; NOMOVBE-NEXT: retq # encoding: [0xc3]37 %bswap = call i16 @llvm.bswap.i16(i16 %y)38 store i16 %bswap, ptr %x, align 239 ret void40}41 42define i16 @test2(ptr %x) nounwind {43; CHECK-LABEL: test2:44; CHECK: # %bb.0:45; CHECK-NEXT: movbew (%rdi), %ax46; CHECK-NEXT: nop47; CHECK-NEXT: nop48; CHECK-NEXT: nop49; CHECK-NEXT: nop50; CHECK-NEXT: nop51; CHECK-NEXT: nop52; CHECK-NEXT: retq53;54; SLM-LABEL: test2:55; SLM: # %bb.0:56; SLM-NEXT: movbew (%rdi), %ax57; SLM-NEXT: retq58;59; EGPR-LABEL: test2:60; EGPR: # %bb.0:61; EGPR-NEXT: movbew (%rdi), %ax # EVEX TO LEGACY Compression encoding: [0x66,0x0f,0x38,0xf0,0x07]62; EGPR-NEXT: retq # encoding: [0xc3]63;64; NOMOVBE-LABEL: test2:65; NOMOVBE: # %bb.0:66; NOMOVBE-NEXT: rolw $8, (%rdi), %ax # encoding: [0x62,0xf4,0x7d,0x18,0xc1,0x07,0x08]67; NOMOVBE-NEXT: retq # encoding: [0xc3]68 %load = load i16, ptr %x, align 269 %bswap = call i16 @llvm.bswap.i16(i16 %load)70 ret i16 %bswap71}72 73define void @test3(ptr nocapture %x, i32 %y) nounwind {74; CHECK-LABEL: test3:75; CHECK: # %bb.0:76; CHECK-NEXT: movbel %esi, (%rdi)77; CHECK-NEXT: nop78; CHECK-NEXT: nop79; CHECK-NEXT: nop80; CHECK-NEXT: nop81; CHECK-NEXT: nop82; CHECK-NEXT: nop83; CHECK-NEXT: retq84;85; SLM-LABEL: test3:86; SLM: # %bb.0:87; SLM-NEXT: movbel %esi, (%rdi)88; SLM-NEXT: retq89;90; EGPR-LABEL: test3:91; EGPR: # %bb.0:92; EGPR-NEXT: movbel %esi, (%rdi) # EVEX TO LEGACY Compression encoding: [0x0f,0x38,0xf1,0x37]93; EGPR-NEXT: retq # encoding: [0xc3]94;95; NOMOVBE-LABEL: test3:96; NOMOVBE: # %bb.0:97; NOMOVBE-NEXT: bswapl %esi # encoding: [0x0f,0xce]98; NOMOVBE-NEXT: movl %esi, (%rdi) # encoding: [0x89,0x37]99; NOMOVBE-NEXT: retq # encoding: [0xc3]100 %bswap = call i32 @llvm.bswap.i32(i32 %y)101 store i32 %bswap, ptr %x, align 4102 ret void103}104 105define i32 @test4(ptr %x) nounwind {106; CHECK-LABEL: test4:107; CHECK: # %bb.0:108; CHECK-NEXT: movbel (%rdi), %eax109; CHECK-NEXT: nop110; CHECK-NEXT: nop111; CHECK-NEXT: nop112; CHECK-NEXT: nop113; CHECK-NEXT: nop114; CHECK-NEXT: nop115; CHECK-NEXT: retq116;117; SLM-LABEL: test4:118; SLM: # %bb.0:119; SLM-NEXT: movbel (%rdi), %eax120; SLM-NEXT: retq121;122; EGPR-LABEL: test4:123; EGPR: # %bb.0:124; EGPR-NEXT: movbel (%rdi), %eax # EVEX TO LEGACY Compression encoding: [0x0f,0x38,0xf0,0x07]125; EGPR-NEXT: retq # encoding: [0xc3]126;127; NOMOVBE-LABEL: test4:128; NOMOVBE: # %bb.0:129; NOMOVBE-NEXT: movl (%rdi), %eax # encoding: [0x8b,0x07]130; NOMOVBE-NEXT: bswapl %eax # encoding: [0x0f,0xc8]131; NOMOVBE-NEXT: retq # encoding: [0xc3]132 %load = load i32, ptr %x, align 4133 %bswap = call i32 @llvm.bswap.i32(i32 %load)134 ret i32 %bswap135}136 137define void @test5(ptr %x, i64 %y) nounwind {138; CHECK-LABEL: test5:139; CHECK: # %bb.0:140; CHECK-NEXT: movbeq %rsi, (%rdi)141; CHECK-NEXT: nop142; CHECK-NEXT: nop143; CHECK-NEXT: nop144; CHECK-NEXT: nop145; CHECK-NEXT: nop146; CHECK-NEXT: nop147; CHECK-NEXT: retq148;149; SLM-LABEL: test5:150; SLM: # %bb.0:151; SLM-NEXT: movbeq %rsi, (%rdi)152; SLM-NEXT: retq153;154; EGPR-LABEL: test5:155; EGPR: # %bb.0:156; EGPR-NEXT: movbeq %rsi, (%rdi) # EVEX TO LEGACY Compression encoding: [0x48,0x0f,0x38,0xf1,0x37]157; EGPR-NEXT: retq # encoding: [0xc3]158;159; NOMOVBE-LABEL: test5:160; NOMOVBE: # %bb.0:161; NOMOVBE-NEXT: bswapq %rsi # encoding: [0x48,0x0f,0xce]162; NOMOVBE-NEXT: movq %rsi, (%rdi) # encoding: [0x48,0x89,0x37]163; NOMOVBE-NEXT: retq # encoding: [0xc3]164 %bswap = call i64 @llvm.bswap.i64(i64 %y)165 store i64 %bswap, ptr %x, align 8166 ret void167}168 169define i64 @test6(ptr %x) nounwind {170; CHECK-LABEL: test6:171; CHECK: # %bb.0:172; CHECK-NEXT: movbeq (%rdi), %rax173; CHECK-NEXT: nop174; CHECK-NEXT: nop175; CHECK-NEXT: nop176; CHECK-NEXT: nop177; CHECK-NEXT: nop178; CHECK-NEXT: nop179; CHECK-NEXT: retq180;181; SLM-LABEL: test6:182; SLM: # %bb.0:183; SLM-NEXT: movbeq (%rdi), %rax184; SLM-NEXT: retq185;186; EGPR-LABEL: test6:187; EGPR: # %bb.0:188; EGPR-NEXT: movbeq (%rdi), %rax # EVEX TO LEGACY Compression encoding: [0x48,0x0f,0x38,0xf0,0x07]189; EGPR-NEXT: retq # encoding: [0xc3]190;191; NOMOVBE-LABEL: test6:192; NOMOVBE: # %bb.0:193; NOMOVBE-NEXT: movq (%rdi), %rax # encoding: [0x48,0x8b,0x07]194; NOMOVBE-NEXT: bswapq %rax # encoding: [0x48,0x0f,0xc8]195; NOMOVBE-NEXT: retq # encoding: [0xc3]196 %load = load i64, ptr %x, align 8197 %bswap = call i64 @llvm.bswap.i64(i64 %load)198 ret i64 %bswap199}200 201define i64 @test7(i64 %x) nounwind {202; CHECK-LABEL: test7:203; CHECK: # %bb.0:204; CHECK-NEXT: movq %rdi, %rax205; CHECK-NEXT: bswapq %rax206; CHECK-NEXT: nop207; CHECK-NEXT: nop208; CHECK-NEXT: nop209; CHECK-NEXT: nop210; CHECK-NEXT: retq211;212; SLM-LABEL: test7:213; SLM: # %bb.0:214; SLM-NEXT: movq %rdi, %rax215; SLM-NEXT: bswapq %rax216; SLM-NEXT: retq217;218; EGPR-LABEL: test7:219; EGPR: # %bb.0:220; EGPR-NEXT: movbeq %rdi, %rax # encoding: [0x62,0xf4,0xfc,0x08,0x61,0xf8]221; EGPR-NEXT: retq # encoding: [0xc3]222;223; NOMOVBE-LABEL: test7:224; NOMOVBE: # %bb.0:225; NOMOVBE-NEXT: movq %rdi, %rax # encoding: [0x48,0x89,0xf8]226; NOMOVBE-NEXT: bswapq %rax # encoding: [0x48,0x0f,0xc8]227; NOMOVBE-NEXT: retq # encoding: [0xc3]228 %bswap = call i64 @llvm.bswap.i64(i64 %x)229 ret i64 %bswap230}231