llvm-project/llvm/test/CodeGen/AMDGPU/structurize1.ll
Fangrui Song 9e9907f1cf
[AMDGPU,test] Change llc -march= to -mtriple= (#75982)
Similar to 806761a7629df268c8aed49657aeccffa6bca449.

For IR files without a target triple, -mtriple= specifies the full
target triple while -march= merely sets the architecture part of the
default target triple, leaving a target triple which may not make sense,
e.g. amdgpu-apple-darwin.

Therefore, -march= is error-prone and not recommended for tests without
a target triple. The issue has been benign as we recognize
$unknown-apple-darwin as ELF instead of rejecting it outrightly.

This patch changes AMDGPU tests to not rely on the default
OS/environment components. Tests that need fixes are not changed:

```
  LLVM :: CodeGen/AMDGPU/fabs.f64.ll
  LLVM :: CodeGen/AMDGPU/fabs.ll
  LLVM :: CodeGen/AMDGPU/floor.ll
  LLVM :: CodeGen/AMDGPU/fneg-fabs.f64.ll
  LLVM :: CodeGen/AMDGPU/fneg-fabs.ll
  LLVM :: CodeGen/AMDGPU/r600-infinite-loop-bug-while-reorganizing-vector.ll
  LLVM :: CodeGen/AMDGPU/schedule-if-2.ll
```
2024-01-16 21:54:58 -08:00

63 lines
1.3 KiB
LLVM

; RUN: llc -mtriple=r600 -mcpu=redwood -r600-if-convert=0 < %s | FileCheck %s
; This tests for abug where the AMDILCFGStructurizer was crashing on loops
; like this:
;
; for (i = 0; i < x; i++) {
; if (cond0) {
; if (cond1) {
;
; } else {
;
; }
; if (cond2) {
;
; }
; }
; }
; CHECK-LABEL: {{^}}if_inside_loop:
; CHECK: LOOP_START_DX10
; CHECK: END_LOOP
define amdgpu_kernel void @if_inside_loop(ptr addrspace(1) %out, i32 %a, i32 %b, i32 %c, i32 %d) {
entry:
br label %for.body
for.body:
%0 = phi i32 [0, %entry], [%inc, %for.inc]
%val = phi i32 [0, %entry], [%val.for.inc, %for.inc]
%inc = add i32 %0, 1
%1 = icmp ult i32 10, %a
br i1 %1, label %for.inc, label %if.then
if.then:
%2 = icmp ne i32 0, %b
br i1 %2, label %if.then.true, label %if.then.false
if.then.true:
%3 = add i32 %a, %val
br label %if
if.then.false:
%4 = mul i32 %a, %val
br label %if
if:
%val.if = phi i32 [%3, %if.then.true], [%4, %if.then.false]
%5 = icmp ne i32 0, %c
br i1 %5, label %if.true, label %for.inc
if.true:
%6 = add i32 %a, %val.if
br label %for.inc
for.inc:
%val.for.inc = phi i32 [%val, %for.body], [%val.if, %if], [%6, %if.true]
%7 = icmp ne i32 0, %d
br i1 %7, label %for.body, label %exit
exit:
store i32 %val.for.inc, ptr addrspace(1) %out
ret void
}