Commit 957c50d9 by Jan Voung

Use lowerCast instead of inlined _movzx, to get legalization, for memset.

Otherwise, there can be a movzx reg, 0, which is illegal, when the memset value is constant 0. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3882 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/402253002
parent 35ec373d
......@@ -2101,7 +2101,8 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
case IceType_v8i1: {
assert(Src0->getType() == IceType_i8);
InstCall *Call = makeHelperCall("Sz_bitcast_i8_to_v8i1", Dest, 1);
Variable *Src0AsI32 = Func->makeVariable(IceType_i32, Context.getNode());
Variable *Src0AsI32 = Func->makeVariable(stackSlotType(),
Context.getNode());
// Arguments to functions are required to be at least 32 bits wide.
lowerCast(InstCast::create(Func, InstCast::Zext, Src0AsI32, Src0));
Call->addArg(Src0AsI32);
......@@ -2110,7 +2111,8 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
case IceType_v16i1: {
assert(Src0->getType() == IceType_i16);
InstCall *Call = makeHelperCall("Sz_bitcast_i16_to_v16i1", Dest, 1);
Variable *Src0AsI32 = Func->makeVariable(IceType_i32, Context.getNode());
Variable *Src0AsI32 = Func->makeVariable(stackSlotType(),
Context.getNode());
// Arguments to functions are required to be at least 32 bits wide.
lowerCast(InstCast::create(Func, InstCast::Zext, Src0AsI32, Src0));
Call->addArg(Src0AsI32);
......@@ -2708,8 +2710,8 @@ void TargetX8632::lowerIntrinsicCall(const InstIntrinsicCall *Instr) {
// because "push" only works for a specific operand size.
Operand *ValOp = Instr->getArg(1);
assert(ValOp->getType() == IceType_i8);
Variable *ValExt = makeReg(stackSlotType());
_movzx(ValExt, ValOp);
Variable *ValExt = Func->makeVariable(stackSlotType(), Context.getNode());
lowerCast(InstCast::create(Func, InstCast::Zext, ValExt, ValOp));
InstCall *Call = makeHelperCall("memset", NULL, 3);
Call->addArg(Instr->getArg(0));
Call->addArg(ValExt);
......
......@@ -132,6 +132,7 @@ entry:
ret void
}
; CHECK-LABEL: test_memset
; CHECK: movzx
; CHECK: call memset
define void @test_memset_const_len_align(i32 %iptr_dst, i32 %wide_val) {
......@@ -143,6 +144,18 @@ entry:
ret void
}
; CHECK-LABEL: test_memset_const_len_align
; CHECK: movzx
; CHECK: call memset
define void @test_memset_const_val(i32 %iptr_dst, i32 %len) {
entry:
%dst = inttoptr i32 %iptr_dst to i8*
call void @llvm.memset.p0i8.i32(i8* %dst, i8 0, i32 %len, i32 1, i1 0)
ret void
}
; CHECK-LABEL: test_memset_const_val
; Make sure the argument is legalized (can't movzx reg, 0).
; CHECK: movzx {{.*}}, {{[^0]}}
; CHECK: call memset
define i32 @test_setjmplongjmp(i32 %iptr_env) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment