Fix legalization of source operand to bsr and bsf.
The source operand to bsr and bsf must be in a register or memory.
BUG=none
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/407093014
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index bfb7274..3808ecb 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -3014,10 +3014,11 @@
// bit position conversion, and the speculation is reversed.
assert(Ty == IceType_i32 || Ty == IceType_i64);
Variable *T = makeReg(IceType_i32);
+ Operand *FirstValRM = legalize(FirstVal, Legal_Mem | Legal_Reg);
if (Cttz) {
- _bsf(T, FirstVal);
+ _bsf(T, FirstValRM);
} else {
- _bsr(T, FirstVal);
+ _bsr(T, FirstValRM);
}
Variable *T_Dest = makeReg(IceType_i32);
Constant *ThirtyTwo = Ctx->getConstantInt(IceType_i32, 32);