-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization
Description
Sometimes, DCE breaks by adding a redundant term.
In the following example, the if statement always evaluates to false. LLVM (14) detects that and removes the dead code:
#include <stdbool.h>
void DCEMarker0_();
void f(bool s, bool sc, bool r, bool cr, bool c) {
if ((((cr && sc && !r) || (c && !c)) && s && (!sc == !(r || r)))) {
DCEMarker0_();
}
}
Now, a redundant disjunction is inserted. LLVM is not able anymore to detect the dead code:
#include <stdbool.h>
void DCEMarker0_();
void f(bool s, bool sc, bool r, bool cr, bool c) {
if (((((cr && sc && !r) || (c && !c)) && s && (!sc == !(r || (r || 0)))))) {
DCEMarker0_();
}
}
This is actually a regression: It worked fine up until LLVM 12.0.1. It has been an issue since LLVM 13.
This can also be seen via the following Compiler Explorer link: https://godbolt.org/z/asrdfj6fs
(Might be related to #56711)
Metadata
Metadata
Assignees
Labels
llvm:instcombineCovers the InstCombine, InstSimplify and AggressiveInstCombine passesCovers the InstCombine, InstSimplify and AggressiveInstCombine passesmissed-optimization