[PATCH] D28374: [x86] fix usage of stale operands in LowerSELECT
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 8 08:04:40 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL291392: [x86] fix usage of stale operands when lowering select (authored by spatel).
Changed prior to commit:
https://reviews.llvm.org/D28374?vs=83288&id=83561#toc
Repository:
rL LLVM
https://reviews.llvm.org/D28374
Files:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/cmov.ll
Index: llvm/trunk/test/CodeGen/X86/cmov.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/cmov.ll
+++ llvm/trunk/test/CodeGen/X86/cmov.ll
@@ -157,16 +157,12 @@
ret i8 %d
}
-; FIXME: The 'not' is redundant.
-
define i32 @smin(i32 %x) {
; CHECK-LABEL: smin:
; CHECK: ## BB#0:
-; CHECK-NEXT: movl %edi, %ecx
-; CHECK-NEXT: notl %ecx
; CHECK-NEXT: xorl $-1, %edi
; CHECK-NEXT: movl $-1, %eax
-; CHECK-NEXT: cmovsl %ecx, %eax
+; CHECK-NEXT: cmovsl %edi, %eax
; CHECK-NEXT: retq
%not_x = xor i32 %x, -1
%1 = icmp slt i32 %not_x, -1
Index: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
@@ -16991,9 +16991,16 @@
return DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, newSelect, zeroConst);
}
- if (Cond.getOpcode() == ISD::SETCC)
- if (SDValue NewCond = LowerSETCC(Cond, DAG))
+ if (Cond.getOpcode() == ISD::SETCC) {
+ if (SDValue NewCond = LowerSETCC(Cond, DAG)) {
Cond = NewCond;
+ // If the condition was updated, it's possible that the operands of the
+ // select were also updated (for example, EmitTest has a RAUW). Refresh
+ // the local references to the select operands in case they got stale.
+ Op1 = Op.getOperand(1);
+ Op2 = Op.getOperand(2);
+ }
+ }
// (select (x == 0), -1, y) -> (sign_bit (x - 1)) | y
// (select (x == 0), y, -1) -> ~(sign_bit (x - 1)) | y
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28374.83561.patch
Type: text/x-patch
Size: 1588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170108/f1d45f9f/attachment.bin>
More information about the llvm-commits
mailing list