Skip to content

Commit 4e4db6f

Browse files
committed
Revert "[SelectionDAG] Use logic right shift to avoid loop hang"
This reverts commit b73229e. It caused LIT failure on non-X86 targets.
1 parent 181d039 commit 4e4db6f

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -5459,6 +5459,9 @@ static SDValue ExpandPowI(const SDLoc &DL, SDValue LHS, SDValue RHS,
54595459

54605460
if (DAG.getTargetLoweringInfo().isBeneficialToExpandPowI(
54615461
Val, DAG.shouldOptForSize())) {
5462+
// Get the exponent as a positive value.
5463+
if (Val < 0)
5464+
Val = -Val;
54625465
// We use the simple binary decomposition method to generate the multiply
54635466
// sequence. There are more optimal ways to do this (for example,
54645467
// powi(x,15) generates one more multiply than it should), but this has
@@ -5478,8 +5481,7 @@ static SDValue ExpandPowI(const SDLoc &DL, SDValue LHS, SDValue RHS,
54785481

54795482
CurSquare = DAG.getNode(ISD::FMUL, DL, CurSquare.getValueType(),
54805483
CurSquare, CurSquare);
5481-
// Use logic right shift
5482-
Val = int(unsigned(Val) >> 1);
5484+
Val >>= 1;
54835485
}
54845486

54855487
// If the original was negative, invert the result, producing 1/(x*x*x).

llvm/test/CodeGen/X86/powi-negative-imm.ll

-21
This file was deleted.

0 commit comments

Comments
 (0)