Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit a8f11c1

Browse files
committed
[X86] Enable isel to use the PAUSE instruction even when SSE2 is disabled
Summary: On older processors this instruction encoding is treated as a NOP. MSVC doesn't disable intrinsics based on features the way clang/gcc does. Because the PAUSE instruction encoding doesn't crash older processors, some software out there uses these intrinsics without checking for SSE2. This change also seems to also be consistent with gcc behavior. Fixes PR34079 Reviewers: RKSimon, zvi Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36361 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310190 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 549896a commit a8f11c1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/Target/X86/X86InstrSSE.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3695,8 +3695,7 @@ let SchedRW = [WriteNop] in {
36953695
// Pause. This "instruction" is encoded as "rep; nop", so even though it
36963696
// was introduced with SSE2, it's backward compatible.
36973697
def PAUSE : I<0x90, RawFrm, (outs), (ins),
3698-
"pause", [(int_x86_sse2_pause)], IIC_SSE_PAUSE>,
3699-
OBXS, Requires<[HasSSE2]>;
3698+
"pause", [(int_x86_sse2_pause)], IIC_SSE_PAUSE>, OBXS;
37003699
}
37013700

37023701
let SchedRW = [WriteFence] in {

test/CodeGen/X86/pause.ll

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=-sse -show-mc-encoding | FileCheck %s
3+
; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=-avx,+sse2 -show-mc-encoding | FileCheck %s
4+
; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mattr=+avx2 -show-mc-encoding | FileCheck %s
5+
; RUN: llc < %s -disable-peephole -mtriple=i386-apple-darwin -mcpu=skx -show-mc-encoding | FileCheck %s
6+
7+
define void @test_x86_sse2_pause() {
8+
; CHECK-LABEL: test_x86_sse2_pause:
9+
; CHECK: ## BB#0:
10+
; CHECK-NEXT: pause ## encoding: [0xf3,0x90]
11+
; CHECK-NEXT: retl ## encoding: [0xc3]
12+
tail call void @llvm.x86.sse2.pause()
13+
ret void
14+
}
15+
declare void @llvm.x86.sse2.pause() nounwind

0 commit comments

Comments
 (0)