From 678d128b5ab6e43582ae642c011b9173607bdb8a Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Wed, 27 Mar 2019 15:43:03 +0000 Subject: [PATCH] [X86MacroFusion][NFC] Improve macrofusion testing. Add negative tests. Add arithmetic/inc/cmp/and macrofusion tests. llvm-svn: 357076 --- llvm/test/CodeGen/X86/testb-je-fusion.ll | 146 ++++++++++++++++++++++++++++--- 1 file changed, 135 insertions(+), 11 deletions(-) diff --git a/llvm/test/CodeGen/X86/testb-je-fusion.ll b/llvm/test/CodeGen/X86/testb-je-fusion.ll index 47453ca..cc09485 100644 --- a/llvm/test/CodeGen/X86/testb-je-fusion.ll +++ b/llvm/test/CodeGen/X86/testb-je-fusion.ll @@ -1,21 +1,35 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=x86_64-- -mcpu=corei7-avx | FileCheck %s +; 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 @check_flag(i32 %flags, ...) nounwind { -; CHECK-LABEL: check_flag: -; CHECK: # %bb.0: # %entry -; CHECK-NEXT: xorl %eax, %eax -; CHECK-NEXT: testl $512, %edi # imm = 0x200 -; CHECK-NEXT: je .LBB0_2 -; CHECK-NEXT: # %bb.1: # %if.then -; CHECK-NEXT: movl $1, %eax -; CHECK-NEXT: .LBB0_2: # %if.end -; CHECK-NEXT: retq +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: @@ -25,3 +39,113 @@ 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 +} -- 2.7.4