mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
2f76252b8b
Summary: EmitTest sometimes creates X86ISD::AND specifically to hide the AND from DAG combine. But this prevents isel patterns that look for (cmp (and X, Y), 0) from being able to see it. So we end up with an AND and a TEST. The TEST gets removed by compare instruction optimization during the peephole pass. This patch attempts to fix this by converting X86ISD::AND with no flag users back into ISD::AND during the DAG preprocessing just before isel. In order to do this correctly I had to make the X86ISD::AND node created by EmitTest in this case really have a flag output. Which arguably it should have had anyway so that the number of operands would be consistent for the opcode in all cases. Then I had to modify the ReplaceAllUsesWith to understand that we might be looking at an instruction with 2 outputs. Though in this case there are no uses to replace since we just created the node, but that's what the code did before so I just made it keep working. Reviewers: spatel, RKSimon, niravd, deadalnix Reviewed By: RKSimon Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42764 llvm-svn: 323982
54 lines
1.3 KiB
LLVM
54 lines
1.3 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
|
|
|
|
; rdar://12081007
|
|
|
|
define i32 @and_1(i8 zeroext %a, i8 zeroext %b, i32 %x) {
|
|
; CHECK-LABEL: and_1:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: testb %dil, %sil
|
|
; CHECK-NEXT: cmovnel %edx, %eax
|
|
; CHECK-NEXT: retq
|
|
%1 = and i8 %b, %a
|
|
%2 = icmp ne i8 %1, 0
|
|
%3 = select i1 %2, i32 %x, i32 0
|
|
ret i32 %3
|
|
}
|
|
|
|
define zeroext i1 @and_2(i8 zeroext %a, i8 zeroext %b) {
|
|
; CHECK-LABEL: and_2:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: testb %dil, %sil
|
|
; CHECK-NEXT: setne %al
|
|
; CHECK-NEXT: retq
|
|
%1 = and i8 %b, %a
|
|
%2 = icmp ne i8 %1, 0
|
|
ret i1 %2
|
|
}
|
|
|
|
define i32 @xor_1(i8 zeroext %a, i8 zeroext %b, i32 %x) {
|
|
; CHECK-LABEL: xor_1:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: xorb %dil, %sil
|
|
; CHECK-NEXT: cmovnel %edx, %eax
|
|
; CHECK-NEXT: retq
|
|
%1 = xor i8 %b, %a
|
|
%2 = icmp ne i8 %1, 0
|
|
%3 = select i1 %2, i32 %x, i32 0
|
|
ret i32 %3
|
|
}
|
|
|
|
define zeroext i1 @xor_2(i8 zeroext %a, i8 zeroext %b) {
|
|
; CHECK-LABEL: xor_2:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: xorb %dil, %sil
|
|
; CHECK-NEXT: setne %al
|
|
; CHECK-NEXT: retq
|
|
%1 = xor i8 %b, %a
|
|
%2 = icmp ne i8 %1, 0
|
|
ret i1 %2
|
|
}
|
|
|