mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 13:40:30 +00:00
[SystemZ] Do not use LOC(G) for volatile loads
It is not safe to use LOAD ON CONDITION to implement access to a memory location marked "volatile", since the architecture leaves it unspecified whether or not an access happens if the condition is false. The current code already appears to care about that: def LOC : CondUnaryRSY<"loc", 0xEBF2, nonvolatile_load, GR32, 4>; Unfortunately, that "nonvolatile_load" operator is simply ignored by the CondUnaryRSY class, and there was no test to catch it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285077 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce0f082662
commit
2677f9fdf7
@ -1665,7 +1665,7 @@ class CondUnaryRSY<string mnemonic, bits<16> opcode,
|
||||
(ins cls:$R1src, mode:$BD2, cond4:$valid, cond4:$R3),
|
||||
mnemonic#"$R3\t$R1, $BD2",
|
||||
[(set cls:$R1,
|
||||
(z_select_ccmask (load bdaddr20only:$BD2), cls:$R1src,
|
||||
(z_select_ccmask (operator bdaddr20only:$BD2), cls:$R1src,
|
||||
cond4:$valid, cond4:$R3))]>,
|
||||
Requires<[FeatureLoadStoreOnCond]> {
|
||||
let Constraints = "$R1 = $R1src";
|
||||
|
@ -128,3 +128,17 @@ exit:
|
||||
%res = phi i32 [ %easy, %entry ], [ %other, %load ]
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
; Test that volatile loads do not use LOC, since if the condition is false,
|
||||
; it is unspecified whether or not the load happens. LOCR is fine though.
|
||||
define i32 @f10(i32 %easy, i32 *%ptr, i32 %limit) {
|
||||
; CHECK-LABEL: f10:
|
||||
; CHECK: l {{%r[0-9]*}}, 0(%r3)
|
||||
; CHECK: locr
|
||||
; CHECK: br %r14
|
||||
%cond = icmp ult i32 %limit, 42
|
||||
%other = load volatile i32, i32 *%ptr
|
||||
%res = select i1 %cond, i32 %easy, i32 %other
|
||||
ret i32 %res
|
||||
}
|
||||
|
||||
|
@ -128,3 +128,17 @@ exit:
|
||||
%res = phi i64 [ %easy, %entry ], [ %other, %load ]
|
||||
ret i64 %res
|
||||
}
|
||||
|
||||
; Test that volatile loads do not use LOCG, since if the condition is false,
|
||||
; it is unspecified whether or not the load happens. LOCGR is fine though.
|
||||
define i64 @f10(i64 %easy, i64 *%ptr, i64 %limit) {
|
||||
; CHECK-LABEL: f10:
|
||||
; CHECK: lg {{%r[0-9]*}}, 0(%r3)
|
||||
; CHECK: locgr
|
||||
; CHECK: br %r14
|
||||
%cond = icmp ult i64 %limit, 42
|
||||
%other = load volatile i64, i64 *%ptr
|
||||
%res = select i1 %cond, i64 %easy, i64 %other
|
||||
ret i64 %res
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user