[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

Bjorn Pettersson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 26 13:09:45 PDT 2021


bjope created this revision.
Herald added subscribers: frasercrmck, jdoerfert, kerbowa, luismarques, apazos, sameer.abuasal, pengfei, s.egerton, Jim, asbirlea, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, atanasyan, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, jgravelle-google, sbc100, nhaehnle, jvesely, nemanjai, sdardis, dylanmckay, dschuff, jholewinski.
bjope requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, aheejin.
Herald added projects: clang, LLVM.

This can be seen as a follow up to commit 0ee439b705e82a4fe20e2 <https://reviews.llvm.org/rG0ee439b705e82a4fe20e266bc8fea96d0e60e1ec>,
that changed the second argument of __powidf2, __powisf2 and
__powitf2 in compiler-rt from si_int to int. That was to align with
how those runtimes are defined in libgcc.
One thing that seem to have been missing in that patch was to make
sure that the rest of LLVM also handle that the argument now depends
on the size of int (not using the si_int machine mode for 32-bit).
When using __builtin_powi for a target with 16-bit int clang crashed.
And when emitting libcalls to those rtlib functions, typically when
lowering @llvm.powi), the backend would always prepare the exponent
argument as an i32 which caused miscompiles when the rtlib was
compiled with 16-bit int.

The solution used here is to use an overloaded type for the second
argument in @llvm.powi. This way clang can use the "correct" type
when lowering __builtin_powi, and then later when emitting the libcall
it is assumed that the type used in @llvm.powi matches the rtlib
function.

One thing that needed some extra attention was that when vectorizing
calls several passes did not support that several arguments could
be overloaded in the intrinsics. This patch allows overload of a
scalar operand by adding hasVectorInstrinsicOverloadedScalarOpd, with
an entry for powi.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99439

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/avr-builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/msp430-builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
  llvm/lib/Target/Mips/Mips16HardFloat.cpp
  llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
  llvm/lib/Transforms/Scalar/Scalarizer.cpp
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
  llvm/test/CodeGen/AArch64/arm64-vfloatintrinsics.ll
  llvm/test/CodeGen/AArch64/f16-instructions.ll
  llvm/test/CodeGen/AArch64/illegal-float-ops.ll
  llvm/test/CodeGen/AArch64/powi-windows.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.powi.ll
  llvm/test/CodeGen/AMDGPU/llvm.powi.ll
  llvm/test/CodeGen/ARM/2011-11-29-128bitArithmetics.ll
  llvm/test/CodeGen/ARM/Windows/powi.ll
  llvm/test/CodeGen/ARM/fp16-fullfp16.ll
  llvm/test/CodeGen/ARM/fp16-promote.ll
  llvm/test/CodeGen/ARM/fpowi.ll
  llvm/test/CodeGen/ARM/vfloatintrinsics.ll
  llvm/test/CodeGen/Generic/fpowi-promote.ll
  llvm/test/CodeGen/Generic/replace-intrinsics-with-veclib.ll
  llvm/test/CodeGen/Mips/mips64-f128.ll
  llvm/test/CodeGen/Mips/msa/f16-llvm-ir.ll
  llvm/test/CodeGen/Mips/powif64_16.ll
  llvm/test/CodeGen/Mips/pr36061.ll
  llvm/test/CodeGen/NVPTX/f16-instructions.ll
  llvm/test/CodeGen/NVPTX/f16x2-instructions.ll
  llvm/test/CodeGen/NVPTX/libcall-intrinsic.ll
  llvm/test/CodeGen/PowerPC/f128-arith.ll
  llvm/test/CodeGen/RISCV/double-intrinsics.ll
  llvm/test/CodeGen/RISCV/float-intrinsics.ll
  llvm/test/CodeGen/RISCV/rv64i-single-softfloat.ll
  llvm/test/CodeGen/SystemZ/fp-libcall.ll
  llvm/test/CodeGen/Thumb2/float-intrinsics-double.ll
  llvm/test/CodeGen/Thumb2/float-intrinsics-float.ll
  llvm/test/CodeGen/Thumb2/intrinsics-cc.ll
  llvm/test/CodeGen/WebAssembly/libcalls.ll
  llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
  llvm/test/CodeGen/X86/2007-09-27-LDIntrinsics.ll
  llvm/test/CodeGen/X86/2010-05-07-ldconvert.ll
  llvm/test/CodeGen/X86/powi-windows.ll
  llvm/test/CodeGen/X86/powi.ll
  llvm/test/CodeGen/X86/tailcall-multiret.ll
  llvm/test/CodeGen/X86/vector-intrinsics.ll
  llvm/test/CodeGen/XCore/float-intrinsics.ll
  llvm/test/Transforms/InstCombine/fdiv.ll
  llvm/test/Transforms/InstCombine/intrinsics.ll
  llvm/test/Transforms/InstCombine/pow-4.ll
  llvm/test/Transforms/InstCombine/pow_fp_int.ll
  llvm/test/Transforms/InstCombine/pow_fp_int16.ll
  llvm/test/Transforms/InstSimplify/ConstProp/math-2.ll
  llvm/test/Transforms/InstSimplify/call.ll
  llvm/test/Transforms/InstSimplify/floating-point-compare.ll
  llvm/test/Transforms/InstSimplify/fold-intrinsics.ll
  llvm/test/Transforms/LICM/hoist-round.ll
  llvm/test/Transforms/LoopVectorize/intrinsic.ll
  llvm/test/Transforms/SLPVectorizer/X86/extract_in_tree_user.ll
  llvm/test/Transforms/SLPVectorizer/X86/intrinsic.ll
  llvm/test/Transforms/Scalarizer/intrinsics.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99439.333615.patch
Type: text/x-patch
Size: 122128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210326/39175b21/attachment-0001.bin>


More information about the cfe-commits mailing list