Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp =================================================================== --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -4035,10 +4035,10 @@ }; 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: test/CodeGen/PowerPC/PR33636.ll =================================================================== --- test/CodeGen/PowerPC/PR33636.ll +++ 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 + +;