[llvm] r185419 - DAGCombiner: fix use-counting issue when forming zextload
Tim Northover
tnorthover at apple.com
Tue Jul 2 02:58:53 PDT 2013
Author: tnorthover
Date: Tue Jul 2 04:58:53 2013
New Revision: 185419
URL: http://llvm.org/viewvc/llvm-project?rev=185419&view=rev
Log:
DAGCombiner: fix use-counting issue when forming zextload
DAGCombiner was counting all uses of a load node when considering whether it's
worth combining into a zextload. Really, it wants to ignore the chain and just
count real uses.
rdar://problem/13896307
Added:
llvm/trunk/test/CodeGen/X86/simple-zext.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=185419&r1=185418&r2=185419&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Tue Jul 2 04:58:53 2013
@@ -2755,7 +2755,7 @@ SDValue DAGCombiner::visitAND(SDNode *N)
? cast<LoadSDNode>(N0.getOperand(0))
: cast<LoadSDNode>(N0);
if (LN0->getExtensionType() != ISD::SEXTLOAD &&
- LN0->isUnindexed() && N0.hasOneUse() && LN0->hasOneUse()) {
+ LN0->isUnindexed() && N0.hasOneUse() && SDValue(LN0, 0).hasOneUse()) {
uint32_t ActiveBits = N1C->getAPIntValue().getActiveBits();
if (ActiveBits > 0 && APIntOps::isMask(ActiveBits, N1C->getAPIntValue())){
EVT ExtVT = EVT::getIntegerVT(*DAG.getContext(), ActiveBits);
Added: llvm/trunk/test/CodeGen/X86/simple-zext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/simple-zext.ll?rev=185419&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/simple-zext.ll (added)
+++ llvm/trunk/test/CodeGen/X86/simple-zext.ll Tue Jul 2 04:58:53 2013
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple=x86_64-apple-darwin < %s| FileCheck %s
+
+; A bug in DAGCombiner prevented it forming a zextload in this simple case
+; because it counted both the chain user and the real user against the
+; profitability total.
+
+define void @load_zext(i32* nocapture %p){
+entry:
+ %0 = load i32* %p, align 4
+ %and = and i32 %0, 255
+ tail call void @use(i32 %and)
+ ret void
+; CHECK: movzbl ({{%r[a-z]+}}), {{%e[a-z]+}}
+}
+
+declare void @use(i32)
More information about the llvm-commits
mailing list