diff options
author | Michael Liao <michael.liao@intel.com> | 2012-08-10 19:58:13 +0000 |
---|---|---|
committer | Michael Liao <michael.liao@intel.com> | 2012-08-10 19:58:13 +0000 |
commit | 5248e9913fc8a0c86fa576ee04752eb0f0133d56 (patch) | |
tree | 36f2262ffbd53c40cf0fe926a00a475337cda3df /llvm/test/CodeGen/X86/bool-simplify.ll | |
parent | a7020aee0004dd9a746e1f9404b10a7bcfdb35b5 (diff) | |
download | bcm5719-llvm-5248e9913fc8a0c86fa576ee04752eb0f0133d56.tar.gz bcm5719-llvm-5248e9913fc8a0c86fa576ee04752eb0f0133d56.zip |
add X86-specific DAG optimization to simplify boolean test
- if a boolean test (X86ISD::CMP or X86ISD:SUB) checks a boolean value
generated from X86ISD::SETCC, try to simplify the boolean value
generation and checking by reusing the original EFLAGS with proper
condition code
- add hooks to X86 specific SETCC/BRCOND/CMOV, the major 3 places
consuming EFLAGS
part of patches fixing PR12312
llvm-svn: 161687
Diffstat (limited to 'llvm/test/CodeGen/X86/bool-simplify.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/bool-simplify.ll | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/bool-simplify.ll b/llvm/test/CodeGen/X86/bool-simplify.ll new file mode 100644 index 00000000000..0cb9fd9bc53 --- /dev/null +++ b/llvm/test/CodeGen/X86/bool-simplify.ll @@ -0,0 +1,42 @@ +; RUN: llc < %s -march=x86-64 -mattr=+sse41,-avx | FileCheck %s + +define i32 @foo(<2 x i64> %c, i32 %a, i32 %b) { + %t1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c) + %t2 = icmp ne i32 %t1, 0 + %t3 = select i1 %t2, i32 %a, i32 %b + ret i32 %t3 +; CHECK: foo +; CHECK: ptest +; CHECK-NOT: testl +; CHECK: cmov +; CHECK: ret +} + +define i32 @bar(<2 x i64> %c) { +entry: + %0 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c) + %1 = icmp ne i32 %0, 0 + br i1 %1, label %if-true-block, label %endif-block +if-true-block: ; preds = %entry + ret i32 0 +endif-block: ; preds = %entry, + ret i32 1 +; CHECK: bar +; CHECK: ptest +; CHECK-NOT: testl +; CHECK: jne +; CHECK: ret +} + +define i32 @bax(<2 x i64> %c) { + %t1 = call i32 @llvm.x86.sse41.ptestz(<2 x i64> %c, <2 x i64> %c) + %t2 = icmp eq i32 %t1, 1 + %t3 = zext i1 %t2 to i32 + ret i32 %t3 +; CHECK: bax +; CHECK: ptest +; CHECK-NOT: cmpl +; CHECK: ret +} + +declare i32 @llvm.x86.sse41.ptestz(<2 x i64>, <2 x i64>) nounwind readnone |