diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 37976337a5fd82..9d6ad1144e292b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -5451,7 +5451,7 @@ static SDValue ExpandPowI(const SDLoc &DL, SDValue LHS, SDValue RHS, // it's beneficial on the target, otherwise we end up lowering to a call to // __powidf2 (for example). if (ConstantSDNode *RHSC = dyn_cast(RHS)) { - int Val = RHSC->getSExtValue(); + int64_t Val = RHSC->getSExtValue(); // powi(x, 0) -> 1.0 if (Val == 0) diff --git a/llvm/test/CodeGen/X86/powi-int32min.ll b/llvm/test/CodeGen/X86/powi-int32min.ll new file mode 100644 index 00000000000000..3a1304c61c49ac --- /dev/null +++ b/llvm/test/CodeGen/X86/powi-int32min.ll @@ -0,0 +1,17 @@ +; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s + +define float @test_powi(ptr %p) nounwind { +; CHECK-LABEL: test_powi: +; CHECK: # %bb.0: # %bb +; 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: retq +bb: + %load = load float, ptr %p, align 4 + %call = call contract float @llvm.powi.f32.i32(float %load, i32 -2147483648) + ret float %call +} + +declare float @llvm.powi.f32.i32(float, i32)