forked from llvm/clangir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRGen][Bugfix] Emit valid type for evaluated const (llvm#456)
This PR fixes the issue connected with folding a simple boolean expresion pattern (f.e. `0 && RHS = 0`). The problem is that the scalar expression emitter always creates a `cir.bool` attribute as a result of expression. But in some cases the result expression should be a `cir.int` attr.
- Loading branch information
Showing
3 changed files
with
28 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir-enable -emit-cir %s -o %t.cir | ||
// RUN: FileCheck --input-file=%t.cir %s | ||
|
||
static const int g = 1; | ||
void foo() { | ||
if ((g != 1) && (g != 1)) | ||
return; | ||
if ((g == 1) || (g == 1)) | ||
return; | ||
} | ||
// CHECK: cir.func no_proto @foo() | ||
// CHECK: cir.scope { | ||
// CHECK: [[ZERO:%.*]] = cir.const(#cir.int<0> : !s32i) : !s32i | ||
// CHECK: [[FALSE:%.*]] = cir.cast(int_to_bool, [[ZERO:%.*]] : !s32i), !cir.bool | ||
// CHECK: cir.if [[FALSE]] { | ||
// CHECK: cir.return | ||
// CHECK: } | ||
// CHECK: } | ||
// CHECK: cir.return | ||
|