# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -o - %s -mtriple=x86_64-- -run-pass peephole-opt -mattr=+ndd | FileCheck %s
---
name: opt_redundant_flags_0
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_0
; CHECK: [[COPY:%[0-9]+]]:gr32 = COPY $esi
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $edi
; CHECK-NEXT: [[SUB32rr_ND:%[0-9]+]]:gr32 = SUB32rr_ND [[COPY]], [[COPY1]], implicit-def $eflags
; CHECK-NEXT: $eax = COPY [[SUB32rr_ND]]
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
%0:gr32 = COPY $esi
%1:gr32 = COPY $edi
%2:gr32 = SUB32rr_ND %0, %1, implicit-def dead $eflags
$eax = COPY %2
; CMP should be removed.
CMP32rr %0, %1, implicit-def $eflags
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_redundant_flags_1
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_1
; CHECK: [[COPY:%[0-9]+]]:gr32 = COPY $esi
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $edi
; CHECK-NEXT: [[SUB32rr_ND:%[0-9]+]]:gr32 = SUB32rr_ND [[COPY]], [[COPY1]], implicit-def $eflags
; CHECK-NEXT: $eax = COPY [[SUB32rr_ND]]
; CHECK-NEXT: $bl = SETCCr 6, implicit $eflags
%0:gr32 = COPY $esi
%1:gr32 = COPY $edi
%2:gr32 = SUB32rr_ND %0, %1, implicit-def dead $eflags
$eax = COPY %2
; CMP should be removed.
CMP32rr %1, %0, implicit-def $eflags
$bl = SETCCr 3, implicit $eflags
...
---
name: opt_redundant_flags_2
body: |
bb.0:
; CHECK-LABEL: name: opt_redundant_flags_2
; CHECK: [[COPY:%[0-9]+]]:gr32 = COPY $esi
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gr32 = COPY $edi
; CHECK-NEXT: [[SUB32rr_ND:%[0-9]+]]:gr32 = SUB32rr_ND [[COPY]], [[COPY1]], implicit-def $eflags
; CHECK-NEXT: $cl = SETCCr 2, implicit $eflags
; CHECK-NEXT: $eax = COPY [[SUB32rr_ND]]
; CHECK-NEXT: $bl = SETCCr 2, implicit $eflags
%0:gr32 = COPY $esi
%1:gr32 = COPY $edi
%2:gr32 = SUB32rr_ND %0, %1, implicit-def $eflags
; an extra eflags reader shouldn't stop optimization.
$cl = SETCCr 2, implicit $eflags
$eax = COPY %2
CMP32rr %0, %1, implicit-def $eflags
$bl = SETCCr 2, implicit $eflags
...
---
name: opt_zerocmp_user_0
body: |
bb.0:
; CHECK-LABEL: name: opt_zerocmp_user_0
; CHECK: [[COPY:%[0-9]+]]:gr32 = COPY $esi
; CHECK-NEXT: [[NEG32r_ND:%[0-9]+]]:gr32 = NEG32r_ND [[COPY]], implicit-def $eflags
; CHECK-NEXT: $al = SETCCr 3, implicit $eflags
%0:gr32 = COPY $esi
%1:gr32 = NEG32r_ND %0, implicit-def dead $eflags
; TEST should be removed.
TEST32rr %0, %0, implicit-def $eflags
$al = SETCCr 4, implicit $eflags
...