Skip to content

Commit cd96f37

Browse files
committed
Move ShiftAmt type conversion outside the if-else so that
it can be applied to all bit widths
1 parent 3a6d57a commit cd96f37

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,8 +2503,6 @@ RValue CodeGenFunction::emitRotate(const CallExpr *E, bool IsRotateRight) {
25032503
// the divisor (2) would be misinterpreted as -2 in 2-bit signed arithmetic.
25042504
llvm::Value *One = ConstantInt::get(ShiftTy, 1);
25052505
ShiftAmt = Builder.CreateAnd(ShiftAmt, One);
2506-
if (ShiftTy != Ty)
2507-
ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
25082506
} else {
25092507
unsigned ShiftAmtBitWidth = ShiftTy->getIntegerBitWidth();
25102508
bool ShiftAmtIsSigned = E->getArg(1)->getType()->isSignedIntegerType();
@@ -2530,11 +2528,11 @@ RValue CodeGenFunction::emitRotate(const CallExpr *E, bool IsRotateRight) {
25302528
} else {
25312529
ShiftAmt = Builder.CreateURem(ShiftAmt, Divisor);
25322530
}
2531+
}
25332532

2534-
// Convert to the source type if needed
2535-
if (ShiftAmt->getType() != Ty) {
2536-
ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
2537-
}
2533+
// Convert to the source type if needed
2534+
if (ShiftAmt->getType() != Ty) {
2535+
ShiftAmt = Builder.CreateIntCast(ShiftAmt, Ty, false);
25382536
}
25392537

25402538
// Rotate is a special case of LLVM funnel shift - 1st 2 args are the same.

0 commit comments

Comments
 (0)