brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 083f418 Raw
115 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 52; RUN: llc -global-isel=0 -mcpu=generic -mtriple=x86_64-apple-darwin %s -o - | FileCheck %s3 4; For all these tests we disable optimizations through function attributes5; because the code we are exercising here needs phis and we want to keep the6; IR small.7 8; This code used to crash in SDISel because bf16 was promoted to f32 through9; a `f32 = vector_extract_elt <1 x bf16>, i32 0`, which is illegal.10; The invalid SDNode and thus, the crash was only exposed by the constant11; folding.12define void @phi_vec1bf16_to_f32_with_const_folding(ptr %dst) #0 {13; CHECK-LABEL: phi_vec1bf16_to_f32_with_const_folding:14; CHECK:       ## %bb.0: ## %entry15; CHECK-NEXT:    pushq %rbx16; CHECK-NEXT:    .cfi_def_cfa_offset 1617; CHECK-NEXT:    .cfi_offset %rbx, -1618; CHECK-NEXT:    movq %rdi, %rbx19; CHECK-NEXT:    jmp LBB0_120; CHECK-NEXT:  LBB0_1: ## %bb21; CHECK-NEXT:    xorps %xmm0, %xmm022; CHECK-NEXT:    callq ___truncsfbf223; CHECK-NEXT:    pextrw $0, %xmm0, %eax24; CHECK-NEXT:    movw %ax, 2(%rbx)25; CHECK-NEXT:    popq %rbx26; CHECK-NEXT:    retq27entry:28  br label %bb29 30bb:31  %phi = phi <1 x bfloat> [ zeroinitializer, %entry ]32  %res = shufflevector <1 x bfloat> poison, <1 x bfloat> %phi, <2 x i32> <i32 0, i32 1>33  store <2 x bfloat> %res, ptr %dst34  ret void35}36; Same as phi_vec1bf16_to_f32_with_const_folding but without the constant37; folding.38; This test exercises the same invalid SDNode, but it happened to work by39; accident before. Here we make sure the fix also work as expected in the40; non-constant folding case.41define void @phi_vec1bf16_to_f32(ptr %src, ptr %dst) #0 {42; CHECK-LABEL: phi_vec1bf16_to_f32:43; CHECK:       ## %bb.0: ## %entry44; CHECK-NEXT:    pushq %rbx45; CHECK-NEXT:    .cfi_def_cfa_offset 1646; CHECK-NEXT:    .cfi_offset %rbx, -1647; CHECK-NEXT:    movq %rsi, %rbx48; CHECK-NEXT:    movzwl (%rdi), %eax49; CHECK-NEXT:    shll $16, %eax50; CHECK-NEXT:    movd %eax, %xmm051; CHECK-NEXT:    jmp LBB1_152; CHECK-NEXT:  LBB1_1: ## %bb53; CHECK-NEXT:    callq ___truncsfbf254; CHECK-NEXT:    pextrw $0, %xmm0, %eax55; CHECK-NEXT:    movw %ax, 2(%rbx)56; CHECK-NEXT:    popq %rbx57; CHECK-NEXT:    retq58entry:59  %input = load <1 x bfloat>, ptr %src60  br label %bb61 62bb:63  %phi = phi <1 x bfloat> [ %input, %entry ]64  %res = shufflevector <1 x bfloat> poison, <1 x bfloat> %phi, <2 x i32> <i32 0, i32 1>65  store <2 x bfloat> %res, ptr %dst66  ret void67}68 69 70; Half type is legal on x86 so nothing special here, but it71; doesn't hurt to be thorough.72define void @phi_vec1half_with_const_folding(ptr %dst) #0 {73; CHECK-LABEL: phi_vec1half_with_const_folding:74; CHECK:       ## %bb.0: ## %entry75; CHECK-NEXT:    xorps %xmm0, %xmm076; CHECK-NEXT:    jmp LBB2_177; CHECK-NEXT:  LBB2_1: ## %bb78; CHECK-NEXT:    pextrw $0, %xmm0, %eax79; CHECK-NEXT:    movw %ax, 2(%rdi)80; CHECK-NEXT:    retq81entry:82  br label %bb83 84bb:85  %phi = phi <1 x half> [ zeroinitializer, %entry ]86  %res = shufflevector <1 x half> poison, <1 x half> %phi, <2 x i32> <i32 0, i32 1>87  store <2 x half> %res, ptr %dst88  ret void89}90 91; Half type is legal on x86 so nothing special here, but it92; doesn't hurt to be thorough.93; Same as phi_vec1half_with_constant_folding but without the constant folding.94define void @phi_vec1half(ptr %src, ptr %dst) #0 {95; CHECK-LABEL: phi_vec1half:96; CHECK:       ## %bb.0: ## %entry97; CHECK-NEXT:    pinsrw $0, (%rdi), %xmm098; CHECK-NEXT:    jmp LBB3_199; CHECK-NEXT:  LBB3_1: ## %bb100; CHECK-NEXT:    pextrw $0, %xmm0, %eax101; CHECK-NEXT:    movw %ax, 2(%rsi)102; CHECK-NEXT:    retq103entry:104  %input = load <1 x half>, ptr %src105  br label %bb106 107bb:108  %phi = phi <1 x half> [ %input, %entry ]109  %res = shufflevector <1 x half> poison, <1 x half> %phi, <2 x i32> <i32 0, i32 1>110  store <2 x half> %res, ptr %dst111  ret void112}113 114attributes #0 = { noinline optnone }115