[PATCH] D114533: LLVM IR should allow bitcast between address spaces with the same size.

krishna chaitanya sankisa via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 24 05:58:42 PST 2021


skc7 created this revision.
skc7 added reviewers: sameerds, arsenm.
Herald added subscribers: dexonsmith, lxfind, jdoerfert, zzheng, hiraditya.
skc7 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

When the addrspacecast instruction was added, the ability to bitcast between pointers from different address spaces was removed.
There are cases, where after analysis, cast between pointers from different address spaces can be concluded to be a no-op cast.
If bitcast can be allowed in these scenarios, it would help further optimise the IR in Transform passes since its a no-op cast.
This enhancement to bitcast will require that pointers to the two address spaces have the same bit widths(can be queried from DataLayout).
Frontend should never misuse the bitcast wherever addrspace cast would have been more appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114533

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/IRBuilderFolder.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/Analysis/LoopUnrollAnalyzer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp
  llvm/lib/Transforms/Utils/VNCoercion.cpp
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-load.ll
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-vector-load.ll
  llvm/test/Transforms/GVN/gvn-eliminate-inttoptr-ptrtoint-for-vector-ptr-load.ll
  llvm/test/Verifier/bitcast-vector-pointer-as-neg.ll
  llvm/test/Verifier/bitcast-vector-pointer-different-addrspace-illegal.ll
  llvm/test/Verifier/bitcast-vector-pointer-neg.ll
  llvm/test/Verifier/bitcast-vector-pointer-pos.ll
  llvm/test/Verifier/bitcast-vector-pointer-same-addrspace.ll
  llvm/unittests/IR/InstructionsTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114533.389478.patch
Type: text/x-patch
Size: 51055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211124/5850ca26/attachment-0001.bin>


More information about the cfe-commits mailing list