
Fixes #131476. For `x86_64` it folds ``` movzbl t1(%rip), %eax andb $1, %al ``` into ``` movzbl t1(%rip), %eax ``` when run: `clang -S atomic-ops-load.c -o atomic-ops-load.s -O1 --target=x86_64`. But for riscv replaces: ``` lb a0, %lo(t1)(a0) andi a0, a0, 1 ``` with ``` lb a0, %lo(t1)(a0) zext.b a0, a0 ``` when run: `clang -S atomic-ops-load.c -o atomic-ops-load.s -O1 --target=riscv64`.
12 lines
397 B
C
12 lines
397 B
C
// RUN: %clang_cc1 -triple riscv64 -O1 -emit-llvm %s -o - | FileCheck %s
|
|
#include <stdbool.h>
|
|
|
|
extern bool t1;
|
|
bool test1(void) {
|
|
// CHECK-LABEL: define{{.*}} i1 @test1
|
|
// CHECK: load atomic i8, ptr @t1 monotonic, align 1, !range ![[$WS_RANGE:[0-9]*]], !noundef !{{[0-9]+}}
|
|
// CHECK-NEXT: trunc nuw i8 %{{.*}} to i1
|
|
// CHECK-NEXT: ret i1 %{{.*}}
|
|
return __atomic_load_n(&t1, __ATOMIC_RELAXED);
|
|
}
|