Skip to content

vector ZExt code generation bug #9639

@llvmbot

Description

@llvmbot
Bugzilla Link 9267
Resolution FIXED
Resolved on Feb 20, 2011 07:39
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor

Extended Description

According to the LangRef, vector Zext are not supported by the spec. However, we would like to enable them. Currently, most vector zext instructions would crash the codegen in various places. For example:

llc: XXX/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:3914: llvm::SDValue llvm::SelectionDAG::getLoad(llvm::ISD::MemIndexedMode, llvm::ISD::LoadExtType, llvm::EVT, llvm::DebugLoc, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::EVT, llvm::MachineMemOperand*): Assertion `VT.isVector() == MemVT.isVector() && "Cannot use trunc store to convert to or from a vector!"' failed.

vector zext is properly expanded to any_extend, except for cases where it is combined with the load operation. The problem is with the DAGcombining pass. In the first round, where it is okay to create illegal types and operations, it creates a complex-zext load. The problem is that there is no legalizer to legalize the newly load in the following stages.

Here is a patch against 2.8. It works on a bunch of test cases that I generated.

Index: DAGCombiner.cpp

--- DAGCombiner.cpp (revision XXX)
+++ DAGCombiner.cpp (working copy)
@@ -3685,8 +3685,7 @@

// fold (zext (load x)) -> (zext (truncate (zextload x)))
if (ISD::isNON_EXTLoad(N0.getNode()) &&

  •  ((!LegalOperations && !cast<LoadSDNode>(N0)->isVolatile()) ||
    
  •   TLI.isLoadExtLegal(ISD::ZEXTLOAD, N0.getValueType()))) {
    
  •  (TLI.isLoadExtLegal(ISD::ZEXTLOAD, N0.getValueType()))) {
    
    bool DoXform = true;
    SmallVector<SDNode*, 4> SetCCs;
    if (!N0.hasOneUse())

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions