Index: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -4034,11 +4034,13 @@ O0.getNode(), O1.getNode()); }; + // FIXME: When the semantics of the interaction between select and undef + // are clearly defined, it may turn out to be unnecessary to break here. SDValue TrueRes = TryFold(ConstTrue); - if (!TrueRes) + if (!TrueRes || TrueRes.isUndef()) break; SDValue FalseRes = TryFold(ConstFalse); - if (!FalseRes) + if (!FalseRes || FalseRes.isUndef()) break; // For us to materialize these using one instruction, we must be able to Index: llvm/trunk/test/CodeGen/PowerPC/PR33636.ll =================================================================== --- llvm/trunk/test/CodeGen/PowerPC/PR33636.ll +++ llvm/trunk/test/CodeGen/PowerPC/PR33636.ll @@ -0,0 +1,702 @@ +; Just a test case for a crash reported in +; https://bugs.llvm.org/show_bug.cgi?id=33636 +; RUN: llc < %s | FileCheck %s +@g_225 = external unnamed_addr global i16, align 2 +@g_756 = external global [6 x i32], align 4 +@g_3456 = external global i32, align 4 +@g_3708 = external global [9 x i32], align 4 +@g_1252 = external global i8*, align 8 +@g_3043 = external global float*, align 8 + +; Function Attrs: nounwind +define void @main() { + br i1 undef, label %1, label %4 + +;