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: 0x{{[0-9a-f]+}}: ch = EntryToken +; CHECK: 0x{{[0-9a-f]+}}: i1 = Constant<1> +; CHECK: 0x{{[0-9a-f]+}}: ch = BasicBlock + br i1 %cmp, label %if.then, label %if.end + +if.then: + ret i32 1 + +if.end: + ret i32 0 +}