Index: lib/CodeGen/TargetSubtargetInfo.cpp =================================================================== --- lib/CodeGen/TargetSubtargetInfo.cpp +++ lib/CodeGen/TargetSubtargetInfo.cpp @@ -68,10 +68,17 @@ } static std::string createSchedInfoStr(unsigned Latency, - Optional RThroughput) { + Optional RThroughput, + TargetSchedModel &TSM) { static const char *SchedPrefix = " sched: ["; std::string Comment; raw_string_ostream CS(Comment); + + // Special-case: if an instruction has no latency (consumes no execution + // resources), then assume that it can execute at the maximum issue width. + if (Latency == 0 && !RThroughput.hasValue()) + RThroughput = 1.0 / TSM.getIssueWidth(); + if (RThroughput.hasValue()) CS << SchedPrefix << Latency << format(":%2.2f", RThroughput.getValue()) << "]"; @@ -91,7 +98,7 @@ TSchedModel.init(this); unsigned Latency = TSchedModel.computeInstrLatency(&MI); Optional RThroughput = TSchedModel.computeReciprocalThroughput(&MI); - return createSchedInfoStr(Latency, RThroughput); + return createSchedInfoStr(Latency, RThroughput, TSchedModel); } /// Returns string representation of scheduler comment @@ -111,7 +118,7 @@ return std::string(); Optional RThroughput = TSchedModel.computeReciprocalThroughput(MCI); - return createSchedInfoStr(Latency, RThroughput); + return createSchedInfoStr(Latency, RThroughput, TSchedModel); } void TargetSubtargetInfo::mirFileLoaded(MachineFunction &MF) const { Index: test/CodeGen/X86/sse-schedule.ll =================================================================== --- test/CodeGen/X86/sse-schedule.ll +++ test/CodeGen/X86/sse-schedule.ll @@ -6225,7 +6225,7 @@ ; ; BTVER2-SSE-LABEL: test_fnop: ; BTVER2-SSE: # %bb.0: -; BTVER2-SSE-NEXT: xorps %xmm0, %xmm0 # sched: [0:?] +; BTVER2-SSE-NEXT: xorps %xmm0, %xmm0 # sched: [0:0.50] ; BTVER2-SSE-NEXT: #APP ; BTVER2-SSE-NEXT: nop # sched: [1:0.50] ; BTVER2-SSE-NEXT: #NO_APP @@ -6233,7 +6233,7 @@ ; ; BTVER2-LABEL: test_fnop: ; BTVER2: # %bb.0: -; BTVER2-NEXT: vxorps %xmm0, %xmm0, %xmm0 # sched: [0:?] +; BTVER2-NEXT: vxorps %xmm0, %xmm0, %xmm0 # sched: [0:0.50] ; BTVER2-NEXT: #APP ; BTVER2-NEXT: nop # sched: [1:0.50] ; BTVER2-NEXT: #NO_APP