-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86] Support immediate folding for CCMP/CTEST (#86616)
E.g. %0:gr32 = MOV32ri 81 CTEST32rr %0, %1, 2, 10, implicit-def $eflags, implicit $eflags => CTEST32ri %1, 81, 2, 10, implicit-def $eflags, implicit $eflags
- Loading branch information
1 parent
79ba323
commit 36b4b9d
Showing
2 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3 | ||
# RUN: llc -mtriple=x86_64-- -run-pass=peephole-opt %s -o - | FileCheck %s | ||
--- | | ||
define void @foldImmediate() { ret void } | ||
... | ||
--- | ||
# Check that immediates can be folded into ALU instructions. | ||
name: foldImmediate | ||
registers: | ||
- { id: 0, class: gr32 } | ||
- { id: 1, class: gr32 } | ||
- { id: 2, class: gr32 } | ||
- { id: 3, class: gr32 } | ||
- { id: 4, class: gr32 } | ||
- { id: 5, class: gr32 } | ||
- { id: 6, class: gr32 } | ||
- { id: 7, class: gr64 } | ||
- { id: 8, class: gr64 } | ||
- { id: 9, class: gr64 } | ||
- { id: 10, class: gr64 } | ||
- { id: 11, class: gr64 } | ||
- { id: 12, class: gr64 } | ||
- { id: 13, class: gr64 } | ||
- { id: 14, class: gr64 } | ||
- { id: 15, class: gr64 } | ||
- { id: 16, class: gr32 } | ||
- { id: 17, class: gr64 } | ||
- { id: 18, class: gr32 } | ||
|
||
body: | | ||
bb.0: | ||
liveins: $rdi, $rsi | ||
; CHECK-LABEL: name: foldImmediate | ||
; CHECK: liveins: $rdi, $rsi | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[MOV32ri:%[0-9]+]]:gr32 = MOV32ri 81 | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi | ||
; CHECK-NEXT: CTEST32ri [[COPY]], 81, 2, 10, implicit-def $eflags, implicit $eflags | ||
; CHECK-NEXT: NOOP implicit $eflags | ||
; CHECK-NEXT: CCMP32ri [[COPY]], 81, 2, 10, implicit-def $eflags, implicit $eflags | ||
; CHECK-NEXT: NOOP implicit $eflags | ||
; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[MOV32ri]], %subreg.sub_32bit | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr64 = COPY $rsi | ||
; CHECK-NEXT: CTEST64ri32 [[COPY1]], 81, 2, 10, implicit-def $eflags, implicit $eflags | ||
; CHECK-NEXT: NOOP implicit $eflags | ||
; CHECK-NEXT: CCMP64ri32 [[COPY1]], 81, 2, 10, implicit-def $eflags, implicit $eflags | ||
; CHECK-NEXT: NOOP implicit $eflags | ||
; CHECK-NEXT: CCMP64rr [[SUBREG_TO_REG]], [[COPY1]], 2, 10, implicit-def $eflags, implicit $eflags | ||
; CHECK-NEXT: NOOP implicit $eflags | ||
%0 = MOV32ri 81 | ||
%1 = COPY $edi | ||
CTEST32rr %0, %1, 2, 10, implicit-def $eflags, implicit $eflags | ||
NOOP implicit $eflags | ||
CCMP32rr %1, %0, 2, 10, implicit-def $eflags, implicit $eflags | ||
NOOP implicit $eflags | ||
%7 = SUBREG_TO_REG 0, killed %0:gr32, %subreg.sub_32bit | ||
%8 = COPY $rsi | ||
CTEST64rr %8, %7, 2, 10, implicit-def $eflags, implicit $eflags | ||
NOOP implicit $eflags | ||
CCMP64rr %8, %7, 2, 10, implicit-def $eflags, implicit $eflags | ||
NOOP implicit $eflags | ||
CCMP64rr %7, %8, 2, 10, implicit-def $eflags, implicit $eflags | ||
NOOP implicit $eflags | ||
... |