1 ; RUN: llc %s -mattr=+avx -o - | FileCheck %s 2 ; PR21743. 3 4 target triple = "x86_64-pc-win32-elf" 5 6 ; Check that copy propagation conservatively assumes that undef register 7 ; can be rewritten by the backend to break false dependencies for the 8 ; hardware. 9 ; In this function we are in this situation: 10 ; reg1 = copy reg2 11 ; = inst reg2<undef> 12 ; reg2 = copy reg1 13 ; Copy propagation used to remove the last copy. 14 ; This is incorrect because the undef flag on reg2 in inst, allows next 15 ; passes to put whatever trashed value in reg2 that may help. 16 ; In practice we end up with this code: 17 ; reg1 = copy reg2 18 ; reg2 = 0 19 ; = inst reg2<undef> 20 ; reg2 = copy reg1 21 ; Therefore, removing the last copy is wrong. 22 ; 23 ; CHECK-LABEL: foo: 24 ; CHECK: movl $339752784, %e[[INDIRECT_CALL1:[a-z]+]] 25 ; CHECK: callq *%r[[INDIRECT_CALL1]] 26 ; Copy the result in a temporary. 27 ; Note: Technically the regalloc could have been smarter and this move not required, 28 ; which would have hidden the bug. 29 ; CHECK-NEXT: vmovapd %xmm0, [[TMP:%xmm[0-9]+]] 30 ; Crush xmm0. 31 ; CHECK-NEXT: vxorps %xmm0, %xmm0, %xmm0 32 ; CHECK: movl $339772768, %e[[INDIRECT_CALL2:[a-z]+]] 33 ; Set TMP in the first argument of the second call. 34 ; CHECK-NEXT: vmovapd [[TMP]], %xmm0 35 ; CHECK: callq *%r[[INDIRECT_CALL2]] 36 ; CHECK: retq 37 define double @foo(i64 %arg) { 38 top: 39 %tmp = call double inttoptr (i64 339752784 to double (double, double)*)(double 1.000000e+00, double 0.000000e+00) 40 %tmp1 = sitofp i64 %arg to double 41 call void inttoptr (i64 339772768 to void (double, double)*)(double %tmp, double %tmp1) 42 %tmp3 = fadd double %tmp1, %tmp 43 ret double %tmp3 44 } 45