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

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: Revert what turned out to be unnecessary changes 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..6237b8a1718647da420649630047caa64cd48698 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -1965,8 +1965,13 @@ 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 {
+ _movzx(T, Src0RM);
jvoung (off chromium) 2014/09/06 17:53:02 Not sure I understand why it's movzx (for a sign-e
Jim Stichnoth 2014/09/06 21:57:27 Clarified in a comment. Movsx/movzx are only need
+ }
_shl(T, ShiftAmount);
_sar(T, ShiftAmount);
_mov(Dest, T);
@@ -2038,6 +2043,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 +2088,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 +2125,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