Index: lib/Support/APInt.cpp =================================================================== --- lib/Support/APInt.cpp +++ lib/Support/APInt.cpp @@ -2159,6 +2159,16 @@ return; } + // Second, check for a one bit value and just short circuit the logic below. + if (*this == 1 && getBitWidth() == 1) { + while (*Prefix) { + Str.push_back(*Prefix); + ++Prefix; + }; + Str.push_back('1'); + return; + } + static const char Digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; if (isSingleWord()) { Index: test/CodeGen/Generic/signed-one-bit-int.ll =================================================================== --- test/CodeGen/Generic/signed-one-bit-int.ll +++ test/CodeGen/Generic/signed-one-bit-int.ll @@ -0,0 +1,16 @@ +; RUN: llc -debug %s -o /dev/null 2>&1 | FileCheck %s + +define i32 @main() #0 { +entry: + %cmp = icmp eq i32 0, 1 +; CHECK: ch = EntryToken +; CHECK-NOT: i1 = Constant<-1> +; CHECK: ch = BasicBlock