[llvm] 4e4db6f - Revert "[SelectionDAG] Use logic right shift to avoid loop hang"
Shengchen Kan via llvm-commits
llvm-commits at lists.llvm.org
Mon May 1 22:14:55 PDT 2023
Author: Shengchen Kan
Date: 2023-05-02T13:14:47+08:00
New Revision: 4e4db6f6c6ce13855d03f1e7a00296e49fed0765
URL: https://github.com/llvm/llvm-project/commit/4e4db6f6c6ce13855d03f1e7a00296e49fed0765
DIFF: https://github.com/llvm/llvm-project/commit/4e4db6f6c6ce13855d03f1e7a00296e49fed0765.diff
LOG: Revert "[SelectionDAG] Use logic right shift to avoid loop hang"
This reverts commit b73229e55543b4ba2b293adcb8b7d6025f01f7d9.
It caused LIT failure on non-X86 targets.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Removed:
llvm/test/CodeGen/X86/powi-negative-imm.ll
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 614de88663ec1..37976337a5fd8 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5459,6 +5459,9 @@ static SDValue ExpandPowI(const SDLoc &DL, SDValue LHS, SDValue RHS,
if (DAG.getTargetLoweringInfo().isBeneficialToExpandPowI(
Val, DAG.shouldOptForSize())) {
+ // Get the exponent as a positive value.
+ if (Val < 0)
+ Val = -Val;
// We use the simple binary decomposition method to generate the multiply
// sequence. There are more optimal ways to do this (for example,
// 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,
CurSquare = DAG.getNode(ISD::FMUL, DL, CurSquare.getValueType(),
CurSquare, CurSquare);
- // Use logic right shift
- Val = int(unsigned(Val) >> 1);
+ Val >>= 1;
}
// If the original was negative, invert the result, producing 1/(x*x*x).
diff --git a/llvm/test/CodeGen/X86/powi-negative-imm.ll b/llvm/test/CodeGen/X86/powi-negative-imm.ll
deleted file mode 100644
index e3e3f51edcbf6..0000000000000
--- a/llvm/test/CodeGen/X86/powi-negative-imm.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
-
-define void @test_powi(ptr %p) nounwind {
-; CHECK-LABEL: powi:
-; CHECK: pushq %rax
-; CHECK-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
-; CHECK-COUNT-31: mulss %xmm1, %xmm1
-; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
-; CHECK-NEXT: divss %xmm1, %xmm0
-; CHECK-NEXT: callq foo at PLT
-; CHECK-NEXT: popq %rax
-; CHECK-NEXT: retq
-bb:
- %load = load float, ptr %p, align 4
- %call1 = call contract float @llvm.powi.f32.i32(float %load, i32 -2147483648)
- %call2 = call i1 @foo(float %call1)
- ret void
-}
-
-declare zeroext i1 @foo(float)
-declare float @llvm.powi.f32.i32(float, i32)
More information about the llvm-commits
mailing list