[all-commits] [llvm/llvm-project] a3c05d: [flang] Fix invalid branch optimization
vdonaldson via All-commits
all-commits at lists.llvm.org
Sun Sep 11 19:38:17 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a3c05df16bc66d8ac84c1b10a74f59b12eb25a94
https://github.com/llvm/llvm-project/commit/a3c05df16bc66d8ac84c1b10a74f59b12eb25a94
Author: V Donaldson <vdonaldson at nvidia.com>
Date: 2022-09-11 (Sun, 11 Sep 2022)
Changed paths:
M flang/lib/Lower/PFTBuilder.cpp
M flang/test/Lower/select-case-statement.f90
Log Message:
-----------
[flang] Fix invalid branch optimization
Branch optimization in function rewriteIfGotos attempts to rewrite code
such as
<<IfConstruct>>
1 If[Then]Stmt: if(cond) goto L
2 GotoStmt: goto L
3 EndIfStmt
<<End IfConstruct>>
4 Statement: ...
5 Statement: ...
6 Statement: L ...
to eliminate a branch and a trivial basic block to get:
<<IfConstruct>>
1 If[Then]Stmt [negate]: if(cond) goto L
4 Statement: ...
5 Statement: ...
3 EndIfStmt
<<End IfConstruct>>
6 Statement: L ...
Among other requirements, this is invalid if any statement between the
GOTO and its target is an intermediate construct statement such as a
CASE or ELSE IF statement, like the CASE DEFAULT statement in:
select case(i)
case (:2)
n = i * 10
case (5:)
n = i * 1000
if (i <= 6) goto 9 ! exit over 'case default'; may not be rewritten
n = i * 10000
case default
n = i * 100
9 end select
More information about the All-commits
mailing list