Fixes #171890 If the pointer operands of an instruction are all constants with generic AS, we always infer the AS of the instruction as uninitialized finally. And the rewrite process will skip cloning the instruction, producing invalid IR. This patch fixes it by inferring the AS of this kind of instruction as flat. Maybe we can fold the operator with all constants to get better performance, but I think this case is rare in the real world.
23 lines
849 B
LLVM
23 lines
849 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
|
|
; RUN: opt -S -passes=infer-address-spaces %s | FileCheck %s
|
|
|
|
target triple = "nvptx64--"
|
|
|
|
define ptr @pr171890(i1 %c) {
|
|
; CHECK-LABEL: define ptr @pr171890(
|
|
; CHECK-SAME: i1 [[C:%.*]]) {
|
|
; CHECK-NEXT: [[ENTRY:.*:]]
|
|
; CHECK-NEXT: [[STACK:%.*]] = alloca i16, align 2
|
|
; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr [[STACK]] to ptr addrspace(5)
|
|
; CHECK-NEXT: [[TMP1:%.*]] = addrspacecast ptr addrspace(5) [[TMP0]] to ptr
|
|
; CHECK-NEXT: [[CONST:%.*]] = getelementptr i8, ptr null, i64 1
|
|
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], ptr [[TMP1]], ptr [[CONST]]
|
|
; CHECK-NEXT: ret ptr [[SEL]]
|
|
;
|
|
entry:
|
|
%stack = alloca i16, align 2
|
|
%const = getelementptr i8, ptr null, i64 1
|
|
%sel = select i1 %c, ptr %stack, ptr %const
|
|
ret ptr %sel
|
|
}
|