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