
This introduces a new `ptrtoaddr` instruction which is similar to `ptrtoint` but has two differences: 1) Unlike `ptrtoint`, `ptrtoaddr` does not capture provenance 2) `ptrtoaddr` only extracts (and then extends/truncates) the low index-width bits of the pointer For most architectures, difference 2) does not matter since index (address) width and pointer representation width are the same, but this does make a difference for architectures that have pointers that aren't just plain integer addresses such as AMDGPU fat pointers or CHERI capabilities. This commit introduces textual and bitcode IR support as well as basic code generation, but optimization passes do not handle the new instruction yet so it may result in worse code than using ptrtoint. Follow-up changes will update capture tracking, etc. for the new instruction. RFC: https://discourse.llvm.org/t/clarifiying-the-semantics-of-ptrtoint/83987/54 Reviewed By: nikic Pull Request: https://github.com/llvm/llvm-project/pull/139357
59 lines
2.0 KiB
LLVM
59 lines
2.0 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
|
|
; RUN: opt -S -passes=normalize < %s | FileCheck %s
|
|
|
|
define double @foo(double %a0, double %a1) {
|
|
; CHECK-LABEL: define double @foo(
|
|
; CHECK-SAME: double [[A0:%.*]], double [[A1:%.*]]) {
|
|
; CHECK-NEXT: [[BB17254:.*:]]
|
|
; CHECK-NEXT: %"vl93562([[A0]], 2.000000e+00)" = fmul double [[A0]], 2.000000e+00
|
|
; CHECK-NEXT: %"op95858(vl93562)" = fmul double 6.000000e+00, %"vl93562([[A0]], 2.000000e+00)"
|
|
; CHECK-NEXT: [[A:%.*]] = fmul double [[A0]], [[A1]]
|
|
; CHECK-NEXT: [[C:%.*]] = fmul double 6.000000e+00, [[A]]
|
|
; CHECK-NEXT: ret double %"op95858(vl93562)"
|
|
;
|
|
entry:
|
|
%a = fmul double %a0, %a1
|
|
%b = fmul double %a0, 2.000000e+00
|
|
%c = fmul double %a, 6.000000e+00
|
|
%d = fmul double %b, 6.000000e+00
|
|
ret double %d
|
|
}
|
|
|
|
declare double @bir()
|
|
|
|
declare double @bar()
|
|
|
|
define double @baz(double %x) {
|
|
; CHECK-LABEL: define double @baz(
|
|
; CHECK-SAME: double [[A0:%.*]]) {
|
|
; CHECK-NEXT: [[BB76951:.*:]]
|
|
; CHECK-NEXT: [[IFCOND:%.*]] = fcmp one double [[A0]], 0.000000e+00
|
|
; CHECK-NEXT: br i1 [[IFCOND]], label %[[BB47054:.*]], label %[[BB470541:.*]]
|
|
; CHECK: [[BB47054]]:
|
|
; CHECK-NEXT: %"vl16994bir()" = call double @bir()
|
|
; CHECK-NEXT: br label %[[BB17254:.*]]
|
|
; CHECK: [[BB470541]]:
|
|
; CHECK-NEXT: %"vl88592bar()" = call double @bar()
|
|
; CHECK-NEXT: br label %[[BB17254]]
|
|
; CHECK: [[BB17254]]:
|
|
; CHECK-NEXT: %"op16411(vl16994, vl88592)" = phi double [ %"vl16994bir()", %[[BB47054]] ], [ %"vl88592bar()", %[[BB470541]] ]
|
|
; CHECK-NEXT: ret double %"op16411(vl16994, vl88592)"
|
|
;
|
|
entry:
|
|
%ifcond = fcmp one double %x, 0.000000e+00
|
|
br i1 %ifcond, label %then, label %else
|
|
|
|
then: ; preds = %entry
|
|
%calltmp = call double @bir()
|
|
br label %ifcont
|
|
|
|
else: ; preds = %entry
|
|
%calltmp1 = call double @bar()
|
|
br label %ifcont
|
|
|
|
ifcont: ; preds = %else, %then
|
|
%iftmp = phi double [ %calltmp, %then ], [ %calltmp1, %else ]
|
|
ret double %iftmp
|
|
}
|
|
|