[llvm-commits] [llvm] r119728 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/2010-11-18-SelectOfExtload.ll

Duncan Sands baldrick at free.fr
Thu Nov 18 12:05:18 PST 2010


Author: baldrick
Date: Thu Nov 18 14:05:18 2010
New Revision: 119728

URL: http://llvm.org/viewvc/llvm-project?rev=119728&view=rev
Log:
The DAGCombiner was threading select over pairs of extending loads even
if the extension types were not the same.  The result was that if you
fed a select with sext and zext loads, as in the testcase, then it
would get turned into a zext (or sext) of the select, which is wrong
in the cases when it should have been an sext (resp. zext).  Reported
and diagnosed by Sebastien Deldon.

Added:
    llvm/trunk/test/CodeGen/X86/2010-11-18-SelectOfExtload.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=119728&r1=119727&r2=119728&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Nov 18 14:05:18 2010
@@ -6658,6 +6658,11 @@
         LLD->isVolatile() || RLD->isVolatile() ||
         // If this is an EXTLOAD, the VT's must match.
         LLD->getMemoryVT() != RLD->getMemoryVT() ||
+        // If this is an EXTLOAD, the kind of extension must match.
+        (LLD->getExtensionType() != RLD->getExtensionType() &&
+         // The only exception is if one of the extensions is anyext.
+         LLD->getExtensionType() != ISD::EXTLOAD &&
+         RLD->getExtensionType() != ISD::EXTLOAD) ||
         // FIXME: this discards src value information.  This is
         // over-conservative. It would be beneficial to be able to remember
         // both potential memory locations.  Since we are discarding

Added: llvm/trunk/test/CodeGen/X86/2010-11-18-SelectOfExtload.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-11-18-SelectOfExtload.ll?rev=119728&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2010-11-18-SelectOfExtload.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2010-11-18-SelectOfExtload.ll Thu Nov 18 14:05:18 2010
@@ -0,0 +1,15 @@
+; RUN: llc < %s -march=x86 | FileCheck %s
+; Both values were being zero extended.
+ at u = external global i8
+ at s = external global i8
+define i32 @foo(i1 %cond) {
+; CHECK: @foo
+  %u_base = load i8* @u
+  %u_val = zext i8 %u_base to i32
+; CHECK: movzbl
+; CHECK: movsbl
+  %s_base = load i8* @s
+  %s_val = sext i8 %s_base to i32
+  %val = select i1 %cond, i32 %u_val, i32 %s_val
+  ret i32 %val
+}





More information about the llvm-commits mailing list