Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: src/IceTargetLoweringX8632.cpp

Issue 547033002: Subzero: Be more strict about i1 calculations. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add comments, clean up test file Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceTargetLoweringX8632.cpp
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 7b977585b5c6e910cb6bc8f2e02f4b678c518d15..54a0afd2e7c3f1224101bcb73b4783eb256be7b1 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -1965,8 +1965,15 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
// dst = t1
size_t DestBits = X86_CHAR_BIT * typeWidthInBytes(Dest->getType());
Constant *ShiftAmount = Ctx->getConstantInt(IceType_i32, DestBits - 1);
- Variable *T = NULL;
- _mov(T, Src0RM);
+ Variable *T = makeReg(Dest->getType());
+ if (typeWidthInBytes(Dest->getType()) <=
+ typeWidthInBytes(Src0RM->getType())) {
+ _mov(T, Src0RM);
+ } else {
+ // Widen the souce using movsx or movzx. (It doesn't matter
halyavin 2014/09/08 06:28:07 FYI: souce->source.
Jim Stichnoth 2014/09/08 17:01:02 Done.
+ // which one, since the following shl/sar overwrite the bits.)
+ _movzx(T, Src0RM);
+ }
_shl(T, ShiftAmount);
_sar(T, ShiftAmount);
_mov(Dest, T);
@@ -2038,6 +2045,8 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
// t1 = trunc Src0RM; Dest = t1
Variable *T = NULL;
_mov(T, Src0RM);
+ if (Dest->getType() == IceType_i1)
+ _and(T, Ctx->getConstantInt(IceType_i1, 1));
_mov(Dest, T);
}
break;
@@ -2081,6 +2090,8 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
Variable *T_2 = makeReg(Dest->getType());
_cvt(T_1, Src0RM);
_mov(T_2, T_1); // T_1 and T_2 may have different integer types
+ if (Dest->getType() == IceType_i1)
+ _and(T_2, Ctx->getConstantInt(IceType_i1, 1));
_mov(Dest, T_2);
T_2->setPreferredRegister(T_1, true);
}
@@ -2116,6 +2127,8 @@ void TargetX8632::lowerCast(const InstCast *Inst) {
Variable *T_2 = makeReg(Dest->getType());
_cvt(T_1, Src0RM);
_mov(T_2, T_1); // T_1 and T_2 may have different integer types
+ if (Dest->getType() == IceType_i1)
+ _and(T_2, Ctx->getConstantInt(IceType_i1, 1));
_mov(Dest, T_2);
T_2->setPreferredRegister(T_1, true);
}

Powered by Google App Engine
This is Rietveld 408576698