Skip to content

Constant prop fails on vector code #9366

@llvmbot

Description

@llvmbot
Bugzilla Link 8994
Resolution FIXED
Resolved on Jan 20, 2011 20:32
Version trunk
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

The instruction combine pass carshes when trying to fold a bitcast from a vector type to a scalar type. Reproduce with:

define i48 @​test(<3 x i1> %icmp1, <3 x i1> %icmp2, i16 addrspace(1)* %dst) nounwind {
entry:
%select1 = select <3 x i1> %icmp1, <3 x i16> zeroinitializer, <3 x i16> <i16 -1, i16 -1, i16 -1>
%select2 = select <3 x i1> %icmp2, <3 x i16> zeroinitializer, <3 x i16> %select1
%tmp2 = bitcast <3 x i16> %select2 to i48
ret i48 %tmp2
}

here's a fix:

Index: InstructionCombining.cpp

--- InstructionCombining.cpp (revision xxx)
+++ InstructionCombining.cpp (revision xxx)
@@ -221,6 +221,12 @@
Instruction *InstCombiner::FoldOpIntoSelect(Instruction &Op, SelectInst *SI) {
// Don't modify shared select instructions
if (!SI->hasOneUse()) return 0;
+

  • // we cannot fold bitcasts which transform a vector to scalars
  • if ( BitCastInst* BI = dyn_cast(&Op) ) {
  • if ( BI->getSrcTy()->isVectorTy() ) return 0;
    
  • }
  • Value *TV = SI->getOperand(1);
    Value *FV = SI->getOperand(2);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions