blob: f766ec00cbc3c071a840cd895ce59885ca5cc800 [file]
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - %s -mtriple=x86_64-- -run-pass peephole-opt | FileCheck %s
---
name: opt_redundant_flags_adjusted_imm_0
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_0
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 1, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 15, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 7, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 14, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 6, implicit $eflags
%0:gr64 = COPY $rsi
; CCMP+SETCC %0 == 1
CCMP64ri32 %0, 1, 2, 5, implicit-def $eflags, implicit $eflags
$cl = SETCCr 4, implicit $eflags
; CCMP+SETCC %0 >= 2; CCMP can be removed.
CCMP64ri32 %0, 2, 2, 5, implicit-def $eflags, implicit $eflags
; %0 >=s 2 --> %0 >s 1
$bl = SETCCr 13, implicit $eflags
; %0 >=u 2 --> %0 >u 1
$bl = SETCCr 3, implicit $eflags
; %0 <s 2 --> %0 <=s 1
$bl = SETCCr 12, implicit $eflags
; %0 <u 2 --> %0 <=u 1
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_1
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_1
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 42, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 5, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 13, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 3, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 12, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
%0:gr64 = COPY $rsi
; CCMP+SETCC %0 != 42
CCMP64ri32 %0, 42, 2, 5, implicit-def $eflags, implicit $eflags
$cl = SETCCr 5, implicit $eflags
; CCMP+SETCC %0 > 41; CCMP can be removed.
CCMP64ri32 %0, 41, 2, 5, implicit-def $eflags, implicit $eflags
; %0 >s 41 --> %0 >=s 42
$bl = SETCCr 15, implicit $eflags
; %0 >u 41 --> %0 >=u 42
$bl = SETCCr 7, implicit $eflags
; %0 <=s 41 --> %0 <s 42
$bl = SETCCr 14, implicit $eflags
; %0 <=u 41 --> %0 <u 42
$bl = SETCCr 6, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_2
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_2
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 1, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 15, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 7, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 14, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 6, implicit $eflags
%0:gr64 = COPY $rsi
%1:gr64 = MOV64ri 1
; CCMP+SETCC %0 == 1
; CCMP64rr will be optimized to CCMP64ri32 in the peephole optimiztion pass
CCMP64rr %0, %1, 2, 5, implicit-def $eflags, implicit $eflags
$cl = SETCCr 4, implicit $eflags
; CCMP+SETCC %0 >= 2; CCMP can be removed.
CCMP64ri32 %0, 2, 2, 5, implicit-def $eflags, implicit $eflags
; %0 >=s 2 --> %0 >s 1
$bl = SETCCr 13, implicit $eflags
; %0 >=u 2 --> %0 >u 1
$bl = SETCCr 3, implicit $eflags
; %0 <s 2 --> %0 <=s 1
$bl = SETCCr 12, implicit $eflags
; %0 <u 2 --> %0 <=u 1
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_3
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_3
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CMP64ri32 [[COPY]], 1, implicit-def $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 15, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 7, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 14, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 6, implicit $eflags
%0:gr64 = COPY $rsi
; CMP+SETCC %0 == 1
CMP64ri32 %0, 1, implicit-def $eflags
$cl = SETCCr 4, implicit $eflags
; CCMP+SETCC %0 >= 2; CCMP can be removed.
CCMP64ri32 %0, 2, 2, 5, implicit-def $eflags, implicit $eflags
; %0 >=s 2 --> %0 >s 1
$bl = SETCCr 13, implicit $eflags
; %0 >=u 2 --> %0 >u 1
$bl = SETCCr 3, implicit $eflags
; %0 <s 2 --> %0 <=s 1
$bl = SETCCr 12, implicit $eflags
; %0 <u 2 --> %0 <=u 1
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_noopt_0
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_noopt_0
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 42, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags
; CHECK-NEXT: CCMP64ri32 [[COPY]], 41, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 4, implicit $eflags
%0:gr64 = COPY $rsi
; CCMP+SETCC %0 <s 1
CCMP64ri32 %0, 42, 2, 5, implicit-def $eflags, implicit $eflags
$cl = SETCCr 4, implicit $eflags
; CCMP should not be removed.
CCMP64ri32 %0, 41, 2, 5, implicit-def $eflags, implicit $eflags
; %0 == 41
$bl = SETCCr 4, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_noopt_1
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_noopt_1
; CHECK: [[COPY:%[0-9]+]]:gr32 = COPY $esi
; CHECK-NEXT: CCMP32ri [[COPY]], 2147483647, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], -2147483648, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 12, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], 4294967295, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], -2147483648, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 12, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], 2147483647, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], -2147483648, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 13, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], 4294967295, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], 0, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], 4294967295, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP32ri [[COPY]], 0, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 3, implicit $eflags
%0:gr32 = COPY $esi
; CCMP+SETCC %0 == INT32_MAX
CCMP32ri %0, 2147483647, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP32ri %0, -2147483648, 2, 5, implicit-def $eflags, implicit $eflags
; %0 <s INT32_MIN
$bl = SETCCr 12, implicit $eflags
CCMP32ri %0, 4294967295, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP32ri %0, -2147483648, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 12, implicit $eflags
CCMP32ri %0, 2147483647, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP32ri %0, -2147483648, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 13, implicit $eflags
CCMP32ri %0, 4294967295, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP32ri %0, 0, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 2, implicit $eflags
CCMP32ri %0, 4294967295, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP32ri %0, 0, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 3, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_noopt_2
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_noopt_2
; CHECK: [[COPY:%[0-9]+]]:gr16 = COPY $cx
; CHECK-NEXT: CCMP16ri [[COPY]], -32768, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 32767, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 15, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 65535, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 32767, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 15, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], -32768, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 32767, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 14, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 0, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 65535, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 4, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 0, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: CCMP16ri [[COPY]], 65535, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 6, implicit $eflags
%0:gr16 = COPY $cx
; CCMP+SETCC %0 == INT16_MIN
CCMP16ri %0, -32768, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP16ri %0, 32767, 2, 5, implicit-def $eflags, implicit $eflags
; %0 >s INT16_MAX
$bl = SETCCr 15, implicit $eflags
CCMP16ri %0, 65535, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP16ri %0, 32767, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 15, implicit $eflags
CCMP16ri %0, -32768, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP16ri %0, 32767, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 14, implicit $eflags
CCMP16ri %0, 0, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP16ri %0, 65535, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 4, implicit $eflags
CCMP16ri %0, 0, 2, 5, implicit-def $eflags, implicit $eflags
; CCMP should not be removed.
CCMP16ri %0, 65535, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 6, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_noopt_3
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_noopt_3
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 1, 2, 7, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags, implicit $eflags
; CHECK-NEXT: CCMP64ri32 [[COPY]], 2, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 13, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 3, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 12, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
%0:gr64 = COPY $rsi
; CCMP+SETCC %0 == 1
CCMP64ri32 %0, 1, 2, 7, implicit-def $eflags, implicit $eflags
$cl = SETCCr 4, implicit $eflags, implicit $eflags
; CCMP+SETCC %0 >= 2; CCMP should not be removed as the scc and dfv is
; different.
CCMP64ri32 %0, 2, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 13, implicit $eflags
$bl = SETCCr 3, implicit $eflags
$bl = SETCCr 12, implicit $eflags
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_noopt_4
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_noopt_4
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 1, 5, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags, implicit $eflags
; CHECK-NEXT: CCMP64ri32 [[COPY]], 2, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 13, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 3, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 12, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
%0:gr64 = COPY $rsi
; CCMP+SETCC %0 == 1
CCMP64ri32 %0, 1, 5, 5, implicit-def $eflags, implicit $eflags
$cl = SETCCr 4, implicit $eflags, implicit $eflags
; CCMP+SETCC %0 >= 2; CCMP should not be removed as the scc and dfv is
; different.
CCMP64ri32 %0, 2, 2, 5, implicit-def $eflags, implicit $eflags
$bl = SETCCr 13, implicit $eflags
$bl = SETCCr 3, implicit $eflags
$bl = SETCCr 12, implicit $eflags
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_redundant_flags_adjusted_imm_noopt_5
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_adjusted_imm_noopt_5
; CHECK: [[COPY:%[0-9]+]]:gr64 = COPY $rsi
; CHECK-NEXT: CCMP64ri32 [[COPY]], 1, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: $cl = SETCCr 4, implicit $eflags
; CHECK-NEXT: CMP64ri32 [[COPY]], 2, implicit-def $eflags
; CHECK-NEXT: $bl = SETCCr 13, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 3, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 12, implicit $eflags
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
%0:gr64 = COPY $rsi
; CCMP+SETCC %0 == 1
CCMP64ri32 %0, 1, 2, 5, implicit-def $eflags, implicit $eflags
$cl = SETCCr 4, implicit $eflags
; CMP+SETCC %0 >= 2; CMP cannot be removed.
CMP64ri32 %0, 2, implicit-def $eflags
; %0 >=s 2 --> %0 >s 1
$bl = SETCCr 13, implicit $eflags
; %0 >=u 2 --> %0 >u 1
$bl = SETCCr 3, implicit $eflags
; %0 <s 2 --> %0 <=s 1
$bl = SETCCr 12, implicit $eflags
; %0 <u 2 --> %0 <=u 1
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_adjusted_imm_multiple_blocks
body: |
; CHECK-LABEL: name: opt_adjusted_imm_multiple_blocks
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $eax
; CHECK-NEXT: CCMP32ri [[COPY]], 20, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: JCC_1 %bb.1, 4, implicit $eflags
; CHECK-NEXT: JMP_1 %bb.3
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
; CHECK-NEXT: liveins: $eflags
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: JCC_1 %bb.2, 15, implicit $eflags
; CHECK-NEXT: JMP_1 %bb.3
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2:
; CHECK-NEXT: successors: %bb.3(0x80000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: JMP_1 %bb.3
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.3:
; CHECK-NEXT: RET 0
bb.0:
%0:gr32 = COPY $eax
CCMP32ri %0, 20, 2, 5, implicit-def $eflags, implicit $eflags
JCC_1 %bb.1, 4, implicit $eflags
JMP_1 %bb.3
bb.1:
CCMP32ri %0, 21, 2, 5, implicit-def $eflags, implicit $eflags
JCC_1 %bb.2, 13, implicit $eflags
JMP_1 %bb.3
bb.2:
JMP_1 %bb.3
bb.3:
RET 0
...
---
name: opt_adjusted_imm_multiple_blocks_noopt
body: |
; CHECK-LABEL: name: opt_adjusted_imm_multiple_blocks_noopt
; CHECK: bb.0:
; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.3(0x40000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $eax
; CHECK-NEXT: CCMP32ri [[COPY]], 20, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: JCC_1 %bb.1, 4, implicit $eflags
; CHECK-NEXT: JMP_1 %bb.3
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.3(0x40000000)
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: CCMP32ri [[COPY]], 21, 2, 5, implicit-def $eflags, implicit $eflags
; CHECK-NEXT: JCC_1 %bb.2, 13, implicit $eflags
; CHECK-NEXT: JMP_1 %bb.3
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.2:
; CHECK-NEXT: successors: %bb.3(0x80000000)
; CHECK-NEXT: liveins: $eflags
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $al = SETCCr 4, implicit $eflags
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.3:
; CHECK-NEXT: RET 0
bb.0:
%0:gr32 = COPY $eax
CCMP32ri %0, 20, 2, 5, implicit-def $eflags, implicit $eflags
JCC_1 %bb.1, 4, implicit $eflags
JMP_1 %bb.3
bb.1:
CCMP32ri %0, 21, 2, 5, implicit-def $eflags, implicit $eflags
JCC_1 %bb.2, 13, implicit $eflags
JMP_1 %bb.3
bb.2:
liveins: $eflags
$al = SETCCr 4, implicit $eflags
bb.3:
RET 0
...