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 = cast(Val)->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, PrevVal->hasOneUse(), 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,18 @@ +; 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" + +%jl_value_t.0 = type { %jl_value_t.0* } + +; Function Attrs: sspreq +declare %jl_value_t.0* @julia_call19(%jl_value_t.0*, %jl_value_t.0*, %jl_value_t.0*, %jl_value_t.0*, i64, %jl_value_t.0*, i1, i64, double) #0 + +define %jl_value_t.0* @jlcall_call19(%jl_value_t.0*, %jl_value_t.0**, i32) { +top: + %3 = load i8* undef + %4 = trunc i8 %3 to i1 + %5 = call %jl_value_t.0* @julia_call19(%jl_value_t.0* undef, %jl_value_t.0* undef, %jl_value_t.0* undef, %jl_value_t.0* undef, i64 undef, %jl_value_t.0* undef, i1 %4, i64 undef, double undef) + ret %jl_value_t.0* %5 +} 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 }