Skip to content

Constant folding cast for zero vectors is missing #9383

@llvmbot

Description

@llvmbot
Bugzilla Link 9011
Resolution FIXED
Resolved on Jan 20, 2011 19:58
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor

Extended Description

There is missing constant folding of casting operation for vector of 0's.
Probably it is due to fact that vector of zeroes is described by ConstantAggregateZero and its handling is missing from ConstantFolding.

As result some of the shaders when running with 'opt -std-compile-opts' may run infinitely long time. See attached .ll for example.

To reproduce the bug just run attached .ll with 'opt -std-compile-opts'

The fix is inlined (due to its simplicity)
Index: lib/VMCore/ConstantFold.cpp

--- lib/VMCore/ConstantFold.cpp (revision 2460)
+++ lib/VMCore/ConstantFold.cpp (working copy)
@@ -553,6 +553,9 @@
return ConstantVector::get(DestVecTy, res);
}

  • if (ConstantAggregateZero *CZ = dyn_cast(V)) {
  •  return Constant::getNullValue(DestTy);
    
  • }
    // We actually have to do a cast now. Perform the cast according to the
    // opcode specified.
    switch (opc) {

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