llvm-project/llvm/test/CodeGen/X86/testb-je-fusion.ll

152 lines
4.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-- -mattr=-macrofusion | FileCheck %s --check-prefix=NOFUSION
; RUN: llc < %s -mtriple=x86_64-- -mattr=+macrofusion | FileCheck %s --check-prefix=MACROFUSION
; testb should be scheduled right before je to enable macro-fusion.
define i32 @macrofuse_test_je(i32 %flags, i8* %p) nounwind {
; NOFUSION-LABEL: macrofuse_test_je:
; NOFUSION: # %bb.0: # %entry
; NOFUSION-NEXT: xorl %eax, %eax
; NOFUSION-NEXT: testl $512, %edi # imm = 0x200
; NOFUSION-NEXT: movb $1, (%rsi)
; NOFUSION-NEXT: je .LBB0_2
; NOFUSION-NEXT: # %bb.1: # %if.then
; NOFUSION-NEXT: movl $1, %eax
; NOFUSION-NEXT: .LBB0_2: # %if.end
; NOFUSION-NEXT: retq
;
; MACROFUSION-LABEL: macrofuse_test_je:
; MACROFUSION: # %bb.0: # %entry
; MACROFUSION-NEXT: xorl %eax, %eax
; MACROFUSION-NEXT: movb $1, (%rsi)
; MACROFUSION-NEXT: testl $512, %edi # imm = 0x200
; MACROFUSION-NEXT: je .LBB0_2
; MACROFUSION-NEXT: # %bb.1: # %if.then
; MACROFUSION-NEXT: movl $1, %eax
; MACROFUSION-NEXT: .LBB0_2: # %if.end
; MACROFUSION-NEXT: retq
entry:
%and = and i32 %flags, 512
%tobool = icmp eq i32 %and, 0
store i8 1, i8* %p
br i1 %tobool, label %if.end, label %if.then
if.then:
br label %if.end
if.end:
%hasflag = phi i32 [ 1, %if.then ], [ 0, %entry ]
ret i32 %hasflag
}
define i32 @macrofuse_cmp_je(i32 %flags, i8* %p) nounwind {
; NOFUSION-LABEL: macrofuse_cmp_je:
; NOFUSION: # %bb.0: # %entry
; NOFUSION-NEXT: cmpl $512, %edi # imm = 0x200
; NOFUSION-NEXT: movb $1, (%rsi)
; NOFUSION-NEXT: je .LBB1_1
; NOFUSION-NEXT: # %bb.2: # %if.then
; NOFUSION-NEXT: movl $1, %eax
; NOFUSION-NEXT: retq
; NOFUSION-NEXT: .LBB1_1:
; NOFUSION-NEXT: xorl %eax, %eax
; NOFUSION-NEXT: retq
;
; MACROFUSION-LABEL: macrofuse_cmp_je:
; MACROFUSION: # %bb.0: # %entry
; MACROFUSION-NEXT: movb $1, (%rsi)
; MACROFUSION-NEXT: cmpl $512, %edi # imm = 0x200
; MACROFUSION-NEXT: je .LBB1_1
; MACROFUSION-NEXT: # %bb.2: # %if.then
; MACROFUSION-NEXT: movl $1, %eax
; MACROFUSION-NEXT: retq
; MACROFUSION-NEXT: .LBB1_1:
; MACROFUSION-NEXT: xorl %eax, %eax
; MACROFUSION-NEXT: retq
entry:
%sub = sub i32 %flags, 512
%tobool = icmp eq i32 %sub, 0
store i8 1, i8* %p
br i1 %tobool, label %if.end, label %if.then
if.then:
br label %if.end
if.end:
%hasflag = phi i32 [ 1, %if.then ], [ 0, %entry ]
ret i32 %hasflag
}
define i32 @macrofuse_alu_je(i32 %flags, i8* %p) nounwind {
; NOFUSION-LABEL: macrofuse_alu_je:
; NOFUSION: # %bb.0: # %entry
; NOFUSION-NEXT: movl %edi, %eax
; NOFUSION-NEXT: addl $-512, %eax # imm = 0xFE00
; NOFUSION-NEXT: movb $1, (%rsi)
; NOFUSION-NEXT: je .LBB2_2
; NOFUSION-NEXT: # %bb.1: # %if.then
; NOFUSION-NEXT: movl $1, %eax
; NOFUSION-NEXT: .LBB2_2: # %if.end
; NOFUSION-NEXT: retq
;
; MACROFUSION-LABEL: macrofuse_alu_je:
; MACROFUSION: # %bb.0: # %entry
; MACROFUSION-NEXT: movl %edi, %eax
; MACROFUSION-NEXT: movb $1, (%rsi)
; MACROFUSION-NEXT: addl $-512, %eax # imm = 0xFE00
; MACROFUSION-NEXT: je .LBB2_2
; MACROFUSION-NEXT: # %bb.1: # %if.then
; MACROFUSION-NEXT: movl $1, %eax
; MACROFUSION-NEXT: .LBB2_2: # %if.end
; MACROFUSION-NEXT: retq
entry:
%sub = sub i32 %flags, 512
%tobool = icmp eq i32 %sub, 0
store i8 1, i8* %p
br i1 %tobool, label %if.end, label %if.then
if.then:
br label %if.end
if.end:
%hasflag = phi i32 [ 1, %if.then ], [ %sub, %entry ]
ret i32 %hasflag
}
define i32 @macrofuse_dec_je(i32 %flags, i8* %p) nounwind {
; NOFUSION-LABEL: macrofuse_dec_je:
; NOFUSION: # %bb.0: # %entry
; NOFUSION-NEXT: movl %edi, %eax
; NOFUSION-NEXT: decl %eax
; NOFUSION-NEXT: movb $1, (%rsi)
; NOFUSION-NEXT: je .LBB3_2
; NOFUSION-NEXT: # %bb.1: # %if.then
; NOFUSION-NEXT: movl $1, %eax
; NOFUSION-NEXT: .LBB3_2: # %if.end
; NOFUSION-NEXT: retq
;
; MACROFUSION-LABEL: macrofuse_dec_je:
; MACROFUSION: # %bb.0: # %entry
; MACROFUSION-NEXT: movl %edi, %eax
; MACROFUSION-NEXT: movb $1, (%rsi)
; MACROFUSION-NEXT: decl %eax
; MACROFUSION-NEXT: je .LBB3_2
; MACROFUSION-NEXT: # %bb.1: # %if.then
; MACROFUSION-NEXT: movl $1, %eax
; MACROFUSION-NEXT: .LBB3_2: # %if.end
; MACROFUSION-NEXT: retq
entry:
%sub = sub i32 %flags, 1
%tobool = icmp eq i32 %sub, 0
store i8 1, i8* %p
br i1 %tobool, label %if.end, label %if.then
if.then:
br label %if.end
if.end:
%hasflag = phi i32 [ 1, %if.then ], [ %sub, %entry ]
ret i32 %hasflag
}