[llvm] [SPIR-V] Fix BB ordering & register lifetime (PR #111026)

Sarah Spall via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 12:46:07 PDT 2024


Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>,
Nathan =?utf-8?q?Gauër?= <brioche at google.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/111026 at github.com>


spall wrote:

It seems enabling mem2reg has introduced what looks like a bug. 
`define noundef i32 @firstbituhigh_i32(i32 noundef %a) {
entry:
   %0 = call i32 @llvm.spv.track.constant.i32.i32(i32 0, metadata i32 0)
   %"reg2mem alloca point" = call i32 @llvm.spv.bitcast.i32.i32(i32 %0)
   call void (i32, ...) @llvm.spv.assign.name.i32(i32 %"reg2mem alloca point", i32 845636978, i32 544040301, i32 1869376609, i32 1881170275, i32 1953393007, i32 0)
   call void @llvm.spv.assign.type.i32(i32 %"reg2mem alloca point", metadata i32 poison)
// ^^ these lines seem to be added by mem2reg pass
  %elt.firstbituhigh = call i32 @llvm.spv.firstbituhigh.i32(i32 %a)
  call void (i32, ...) @llvm.spv.assign.name.i32(i32 %elt.firstbituhigh, i32 779381861, i32 1936877926, i32 1953063540, i32 1734961269, i32 104)
  call void @llvm.spv.assign.type.i32(i32 %elt.firstbituhigh, metadata i32 poison)
  ret i32 %elt.firstbituhigh`
  
  The bitcast added by mem2reg manifests in this bitcast (%25)
  `    %1 = OpTypeInt 32 0
       %16 = OpConstant %1 0
       %24 = OpFunction %1 None %2             ; -- Begin function firstbituhigh_i32
        %23 = OpFunctionParameter %1
        %84 = OpLabel
        %25 = OpBitcast %1 %16
        %26 = OpExtInst %1 %27 FindUMsb %23
        OpReturnValue %26
        OpFunctionEnd`
        
        The PR this is affecting this test: https://github.com/llvm/llvm-project/pull/111082/files#diff-b0dbfa444f4440132c78ce0a3d8ecd397efab944b4f5d83679691361d6cf0afa. After rebasing the bitcast appears in all of the tests in that file. 

https://github.com/llvm/llvm-project/pull/111026


More information about the llvm-commits mailing list