Index: lib/Target/X86/X86ScheduleBtVer2.td =================================================================== --- lib/Target/X86/X86ScheduleBtVer2.td +++ lib/Target/X86/X86ScheduleBtVer2.td @@ -595,6 +595,10 @@ let Latency = 0; } +def JWriteZeroIdiomYmm : SchedWriteRes<[JFPU01, JFPX]> { + let NumMicroOps = 2; +} + // Certain instructions that use the same register for both source // operands do not have a real dependency on the previous contents of the // register, and thus, do not have to wait before completing. They can be @@ -619,6 +623,13 @@ ANDNPSrr, VANDNPSrr, ANDNPDrr, VANDNPDrr)>; +def JWriteFZeroIdiomY : SchedWriteVariant<[ + SchedVar, [JWriteZeroIdiomYmm]>, + SchedVar +]>; +def : InstRW<[JWriteFZeroIdiomY], (instrs VXORPSYrr, VXORPDYrr, + VANDNPSYrr, VANDNPDYrr)>; + def JWriteVZeroIdiomLogic : SchedWriteVariant<[ SchedVar, [JWriteZeroLatency]>, SchedVar Index: test/CodeGen/X86/avx-schedule.ll =================================================================== --- test/CodeGen/X86/avx-schedule.ll +++ test/CodeGen/X86/avx-schedule.ll @@ -5424,6 +5424,90 @@ call void @llvm.x86.avx.vzeroupper() ret void } + +define void @test_avx256_zero_idioms() { +; GENERIC-LABEL: test_avx256_zero_idioms: +; GENERIC: # %bb.0: +; GENERIC-NEXT: #APP +; GENERIC-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:1.00] +; GENERIC-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:1.00] +; GENERIC-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:1.00] +; GENERIC-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:1.00] +; GENERIC-NEXT: #NO_APP +; GENERIC-NEXT: retq # sched: [1:1.00] +; +; SANDY-LABEL: test_avx256_zero_idioms: +; SANDY: # %bb.0: +; SANDY-NEXT: #APP +; SANDY-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:1.00] +; SANDY-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:1.00] +; SANDY-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:1.00] +; SANDY-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:1.00] +; SANDY-NEXT: #NO_APP +; SANDY-NEXT: retq # sched: [1:1.00] +; +; HASWELL-LABEL: test_avx256_zero_idioms: +; HASWELL: # %bb.0: +; HASWELL-NEXT: #APP +; HASWELL-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:1.00] +; HASWELL-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:1.00] +; HASWELL-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:1.00] +; HASWELL-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:1.00] +; HASWELL-NEXT: #NO_APP +; HASWELL-NEXT: retq # sched: [7:1.00] +; +; BROADWELL-LABEL: test_avx256_zero_idioms: +; BROADWELL: # %bb.0: +; BROADWELL-NEXT: #APP +; BROADWELL-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:1.00] +; BROADWELL-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:1.00] +; BROADWELL-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:1.00] +; BROADWELL-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:1.00] +; BROADWELL-NEXT: #NO_APP +; BROADWELL-NEXT: retq # sched: [7:1.00] +; +; SKYLAKE-LABEL: test_avx256_zero_idioms: +; SKYLAKE: # %bb.0: +; SKYLAKE-NEXT: #APP +; SKYLAKE-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:0.33] +; SKYLAKE-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:0.33] +; SKYLAKE-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:0.33] +; SKYLAKE-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:0.33] +; SKYLAKE-NEXT: #NO_APP +; SKYLAKE-NEXT: retq # sched: [7:1.00] +; +; SKX-LABEL: test_avx256_zero_idioms: +; SKX: # %bb.0: +; SKX-NEXT: #APP +; SKX-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:0.33] +; SKX-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:0.33] +; SKX-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:0.33] +; SKX-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:0.33] +; SKX-NEXT: #NO_APP +; SKX-NEXT: retq # sched: [7:1.00] +; +; BTVER2-LABEL: test_avx256_zero_idioms: +; BTVER2: # %bb.0: +; BTVER2-NEXT: #APP +; BTVER2-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:0.50] +; BTVER2-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:0.50] +; BTVER2-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:0.50] +; BTVER2-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:0.50] +; BTVER2-NEXT: #NO_APP +; BTVER2-NEXT: retq # sched: [4:1.00] +; +; ZNVER1-LABEL: test_avx256_zero_idioms: +; ZNVER1: # %bb.0: +; ZNVER1-NEXT: #APP +; ZNVER1-NEXT: vxorps %ymm0, %ymm0, %ymm0 # sched: [1:0.25] +; ZNVER1-NEXT: vxorpd %ymm1, %ymm1, %ymm1 # sched: [1:0.25] +; ZNVER1-NEXT: vandnps %ymm2, %ymm2, %ymm2 # sched: [1:0.25] +; ZNVER1-NEXT: vandnpd %ymm3, %ymm3, %ymm3 # sched: [1:0.25] +; ZNVER1-NEXT: #NO_APP +; ZNVER1-NEXT: retq # sched: [1:0.50] + call void asm sideeffect "vxorps %ymm0, %ymm0, %ymm0\0Avxorpd %ymm1, %ymm1, %ymm1\0Avandnps %ymm2, %ymm2, %ymm2\0Avandnpd %ymm3, %ymm3, %ymm3", ""() + ret void +} declare void @llvm.x86.avx.vzeroupper() nounwind !0 = !{i32 1} Index: test/tools/llvm-mca/X86/BtVer2/zero-idioms-avx-256.s =================================================================== --- test/tools/llvm-mca/X86/BtVer2/zero-idioms-avx-256.s +++ test/tools/llvm-mca/X86/BtVer2/zero-idioms-avx-256.s @@ -35,12 +35,12 @@ # CHECK: Iterations: 100 # CHECK-NEXT: Instructions: 300 -# CHECK-NEXT: Total Cycles: 306 +# CHECK-NEXT: Total Cycles: 304 # CHECK-NEXT: Total uOps: 600 # CHECK: Dispatch Width: 2 -# CHECK-NEXT: uOps Per Cycle: 1.96 -# CHECK-NEXT: IPC: 0.98 +# CHECK-NEXT: uOps Per Cycle: 1.97 +# CHECK-NEXT: IPC: 0.99 # CHECK-NEXT: Block RThroughput: 3.0 # CHECK: Instruction Info: @@ -53,7 +53,7 @@ # CHECK: [1] [2] [3] [4] [5] [6] Instructions: # CHECK-NEXT: 2 3 2.00 vaddps %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: 2 1 1.00 vxorps %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: 2 1 0.50 vxorps %ymm1, %ymm1, %ymm1 # CHECK-NEXT: 2 1 1.00 vblendps $2, %ymm1, %ymm2, %ymm3 # CHECK: Resources: @@ -74,27 +74,27 @@ # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] -# CHECK-NEXT: - - - 3.00 3.00 3.00 3.00 - - - - - - - +# CHECK-NEXT: - - - 3.00 2.00 3.00 2.00 - - - - - - - # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] Instructions: # CHECK-NEXT: - - - 2.00 - 2.00 - - - - - - - - vaddps %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: - - - - 2.00 - 2.00 - - - - - - - vxorps %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: - - - - 1.00 - 1.00 - - - - - - - vxorps %ymm1, %ymm1, %ymm1 # CHECK-NEXT: - - - 1.00 1.00 1.00 1.00 - - - - - - - vblendps $2, %ymm1, %ymm2, %ymm3 # CHECK: Timeline view: -# CHECK-NEXT: 012 +# CHECK-NEXT: 0123 # CHECK-NEXT: Index 0123456789 -# CHECK: [0,0] DeeeER . . vaddps %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: [0,1] .DeE-R . . vxorps %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: [0,2] . DeE-R . . vblendps $2, %ymm1, %ymm2, %ymm3 -# CHECK-NEXT: [1,0] . D=eeeER. . vaddps %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: [1,1] . DeE--R. . vxorps %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: [1,2] . D=eE-R . vblendps $2, %ymm1, %ymm2, %ymm3 -# CHECK-NEXT: [2,0] . .DeeeER. vaddps %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: [2,1] . . D=eER. vxorps %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: [2,2] . . D=eER vblendps $2, %ymm1, %ymm2, %ymm3 +# CHECK: [0,0] DeeeER . . vaddps %ymm0, %ymm0, %ymm1 +# CHECK-NEXT: [0,1] .DeE-R . . vxorps %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: [0,2] . DeE-R . . vblendps $2, %ymm1, %ymm2, %ymm3 +# CHECK-NEXT: [1,0] . DeeeER . . vaddps %ymm0, %ymm0, %ymm1 +# CHECK-NEXT: [1,1] . DeE-R . . vxorps %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: [1,2] . DeE-R. . vblendps $2, %ymm1, %ymm2, %ymm3 +# CHECK-NEXT: [2,0] . .D=eeeER. vaddps %ymm0, %ymm0, %ymm1 +# CHECK-NEXT: [2,1] . . DeE--R. vxorps %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: [2,2] . . DeE--R vblendps $2, %ymm1, %ymm2, %ymm3 # CHECK: Average Wait times (based on the timeline view): # CHECK-NEXT: [0]: Executions @@ -104,19 +104,19 @@ # CHECK: [0] [1] [2] [3] # CHECK-NEXT: 0. 3 1.3 1.3 0.0 vaddps %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: 1. 3 1.3 1.3 1.0 vxorps %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: 2. 3 1.7 0.3 0.7 vblendps $2, %ymm1, %ymm2, %ymm3 +# CHECK-NEXT: 1. 3 1.0 1.0 1.3 vxorps %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: 2. 3 1.0 0.0 1.3 vblendps $2, %ymm1, %ymm2, %ymm3 # CHECK: [1] Code Region - ZERO-IDIOM-2 # CHECK: Iterations: 100 # CHECK-NEXT: Instructions: 300 -# CHECK-NEXT: Total Cycles: 306 +# CHECK-NEXT: Total Cycles: 304 # CHECK-NEXT: Total uOps: 600 # CHECK: Dispatch Width: 2 -# CHECK-NEXT: uOps Per Cycle: 1.96 -# CHECK-NEXT: IPC: 0.98 +# CHECK-NEXT: uOps Per Cycle: 1.97 +# CHECK-NEXT: IPC: 0.99 # CHECK-NEXT: Block RThroughput: 3.0 # CHECK: Instruction Info: @@ -129,7 +129,7 @@ # CHECK: [1] [2] [3] [4] [5] [6] Instructions: # CHECK-NEXT: 2 3 2.00 vaddpd %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: 2 1 1.00 vxorpd %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: 2 1 0.50 vxorpd %ymm1, %ymm1, %ymm1 # CHECK-NEXT: 2 1 1.00 vblendpd $2, %ymm1, %ymm2, %ymm3 # CHECK: Resources: @@ -150,27 +150,27 @@ # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] -# CHECK-NEXT: - - - 3.00 3.00 3.00 3.00 - - - - - - - +# CHECK-NEXT: - - - 3.00 2.00 3.00 2.00 - - - - - - - # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] Instructions: # CHECK-NEXT: - - - 2.00 - 2.00 - - - - - - - - vaddpd %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: - - - - 2.00 - 2.00 - - - - - - - vxorpd %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: - - - - 1.00 - 1.00 - - - - - - - vxorpd %ymm1, %ymm1, %ymm1 # CHECK-NEXT: - - - 1.00 1.00 1.00 1.00 - - - - - - - vblendpd $2, %ymm1, %ymm2, %ymm3 # CHECK: Timeline view: -# CHECK-NEXT: 012 +# CHECK-NEXT: 0123 # CHECK-NEXT: Index 0123456789 -# CHECK: [0,0] DeeeER . . vaddpd %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: [0,1] .DeE-R . . vxorpd %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: [0,2] . DeE-R . . vblendpd $2, %ymm1, %ymm2, %ymm3 -# CHECK-NEXT: [1,0] . D=eeeER. . vaddpd %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: [1,1] . DeE--R. . vxorpd %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: [1,2] . D=eE-R . vblendpd $2, %ymm1, %ymm2, %ymm3 -# CHECK-NEXT: [2,0] . .DeeeER. vaddpd %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: [2,1] . . D=eER. vxorpd %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: [2,2] . . D=eER vblendpd $2, %ymm1, %ymm2, %ymm3 +# CHECK: [0,0] DeeeER . . vaddpd %ymm0, %ymm0, %ymm1 +# CHECK-NEXT: [0,1] .DeE-R . . vxorpd %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: [0,2] . DeE-R . . vblendpd $2, %ymm1, %ymm2, %ymm3 +# CHECK-NEXT: [1,0] . DeeeER . . vaddpd %ymm0, %ymm0, %ymm1 +# CHECK-NEXT: [1,1] . DeE-R . . vxorpd %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: [1,2] . DeE-R. . vblendpd $2, %ymm1, %ymm2, %ymm3 +# CHECK-NEXT: [2,0] . .D=eeeER. vaddpd %ymm0, %ymm0, %ymm1 +# CHECK-NEXT: [2,1] . . DeE--R. vxorpd %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: [2,2] . . DeE--R vblendpd $2, %ymm1, %ymm2, %ymm3 # CHECK: Average Wait times (based on the timeline view): # CHECK-NEXT: [0]: Executions @@ -180,8 +180,8 @@ # CHECK: [0] [1] [2] [3] # CHECK-NEXT: 0. 3 1.3 1.3 0.0 vaddpd %ymm0, %ymm0, %ymm1 -# CHECK-NEXT: 1. 3 1.3 1.3 1.0 vxorpd %ymm1, %ymm1, %ymm1 -# CHECK-NEXT: 2. 3 1.7 0.3 0.7 vblendpd $2, %ymm1, %ymm2, %ymm3 +# CHECK-NEXT: 1. 3 1.0 1.0 1.3 vxorpd %ymm1, %ymm1, %ymm1 +# CHECK-NEXT: 2. 3 1.0 0.0 1.3 vblendpd $2, %ymm1, %ymm2, %ymm3 # CHECK: [2] Code Region - ZERO-IDIOM-3 @@ -205,7 +205,7 @@ # CHECK: [1] [2] [3] [4] [5] [6] Instructions: # CHECK-NEXT: 2 3 2.00 vaddps %ymm0, %ymm1, %ymm2 -# CHECK-NEXT: 2 1 1.00 vandnps %ymm2, %ymm2, %ymm3 +# CHECK-NEXT: 2 1 0.50 vandnps %ymm2, %ymm2, %ymm3 # CHECK: Resources: # CHECK-NEXT: [0] - JALU0 @@ -225,12 +225,12 @@ # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] -# CHECK-NEXT: - - - 2.00 2.00 2.00 2.00 - - - - - - - +# CHECK-NEXT: - - - 2.00 1.00 2.00 1.00 - - - - - - - # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] Instructions: # CHECK-NEXT: - - - 2.00 - 2.00 - - - - - - - - vaddps %ymm0, %ymm1, %ymm2 -# CHECK-NEXT: - - - - 2.00 - 2.00 - - - - - - - vandnps %ymm2, %ymm2, %ymm3 +# CHECK-NEXT: - - - - 1.00 - 1.00 - - - - - - - vandnps %ymm2, %ymm2, %ymm3 # CHECK: Timeline view: # CHECK-NEXT: Index 0123456789 @@ -274,7 +274,7 @@ # CHECK: [1] [2] [3] [4] [5] [6] Instructions: # CHECK-NEXT: 2 3 2.00 vaddps %ymm0, %ymm1, %ymm2 -# CHECK-NEXT: 2 1 1.00 vandnps %ymm2, %ymm2, %ymm3 +# CHECK-NEXT: 2 1 0.50 vandnps %ymm2, %ymm2, %ymm3 # CHECK: Resources: # CHECK-NEXT: [0] - JALU0 @@ -294,12 +294,12 @@ # CHECK: Resource pressure per iteration: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] -# CHECK-NEXT: - - - 2.00 2.00 2.00 2.00 - - - - - - - +# CHECK-NEXT: - - - 2.00 1.00 2.00 1.00 - - - - - - - # CHECK: Resource pressure by instruction: # CHECK-NEXT: [0] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] Instructions: # CHECK-NEXT: - - - 2.00 - 2.00 - - - - - - - - vaddps %ymm0, %ymm1, %ymm2 -# CHECK-NEXT: - - - - 2.00 - 2.00 - - - - - - - vandnps %ymm2, %ymm2, %ymm3 +# CHECK-NEXT: - - - - 1.00 - 1.00 - - - - - - - vandnps %ymm2, %ymm2, %ymm3 # CHECK: Timeline view: # CHECK-NEXT: Index 0123456789