Index: lib/Target/X86/X86FastISel.cpp =================================================================== --- lib/Target/X86/X86FastISel.cpp +++ lib/Target/X86/X86FastISel.cpp @@ -2695,18 +2695,18 @@ if (TI->getType()->isIntegerTy(1) && CLI.CS && (TI->getParent() == CLI.CS->getInstruction()->getParent()) && TI->hasOneUse()) { - Val = cast(Val)->getOperand(0); - unsigned ResultReg = getRegForValue(Val); + Value *PrevVal = TI->getOperand(0); + unsigned ResultReg = getRegForValue(PrevVal); if (!ResultReg) return false; MVT ArgVT; - if (!isTypeLegal(Val->getType(), ArgVT)) + if (!isTypeLegal(PrevVal->getType(), ArgVT)) return false; ResultReg = - fastEmit_ri(ArgVT, ArgVT, ISD::AND, ResultReg, Val->hasOneUse(), 1); + fastEmit_ri(ArgVT, ArgVT, ISD::AND, ResultReg, hasTrivialKill(PrevVal), 1); if (!ResultReg) return false; Index: test/CodeGen/X86/fast-isel-call-bool.ll =================================================================== --- /dev/null +++ test/CodeGen/X86/fast-isel-call-bool.ll @@ -0,0 +1,16 @@ +; RUN: llc < %s -fast-isel -mcpu=core2 -O1 +; See PR21557 + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-darwin14.0.0" + +; Function Attrs: sspreq +declare i64 @bar(i1) + +define i64 @foo() { +top: + %0 = load i8* undef + %1 = trunc i8 %0 to i1 + %2 = call i64 @bar(i1 %1) + ret i64 %2 +} Index: test/CodeGen/X86/fast-isel-x86-64.ll =================================================================== --- test/CodeGen/X86/fast-isel-x86-64.ll +++ test/CodeGen/X86/fast-isel-x86-64.ll @@ -167,7 +167,7 @@ call void @test13f(i1 zeroext %tobool) noredzone ret void ; CHECK-LABEL: test14: -; CHECK: andb $1, +; CHECK: andl $1, ; CHECK: callq }