[PATCH] D26432: [SCCP] Force unknown branches to overdefined

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 16:37:28 PST 2016


davide created this revision.
davide added a reviewer: eli.friedman.
davide added a subscriber: llvm-commits.

See https://llvm.org/bugs/show_bug.cgi?id=30448 for the full discussion, and thanks to Eli helping finding the problem


https://reviews.llvm.org/D26432

Files:
  lib/Transforms/Scalar/SCCP.cpp
  test/Transforms/SCCP/apint-ipsccp3.ll
  test/Transforms/SCCP/ipsccp-basic.ll


Index: test/Transforms/SCCP/ipsccp-basic.ll
===================================================================
--- test/Transforms/SCCP/ipsccp-basic.ll
+++ test/Transforms/SCCP/ipsccp-basic.ll
@@ -55,8 +55,9 @@
 	ret void
 }
 ; CHECK-LABEL: define void @test3a(
-; CHECK-NEXT: ret void
-
+; CHECK-NEXT:   %X = load i32, i32* @G
+; CHECK-NEXT:   store i32 %X, i32* @G
+; CHECK-NEXT:   ret void
 
 define i32 @test3b() {
 	%V = load i32, i32* @G
@@ -70,7 +71,8 @@
 	ret i32 0
 }
 ; CHECK-LABEL: define i32 @test3b(
-; CHECK-NOT: store
+; CHECK: store i32 17, i32* @G
+; CHECK: store i32 123, i32* @G
 ; CHECK: ret i32 0
 
 
Index: test/Transforms/SCCP/apint-ipsccp3.ll
===================================================================
--- test/Transforms/SCCP/apint-ipsccp3.ll
+++ test/Transforms/SCCP/apint-ipsccp3.ll
@@ -1,8 +1,24 @@
-; RUN: opt < %s -ipsccp -S | not grep global
-
- at G = internal global i66 undef
+; RUN: opt < %s -ipsccp -S | FileCheck %s
 
+; CHECK: @G = internal global i66 undef
+; CHECK: define void @foo() {
+; CHECK:   %X = load i66, i66* @G
+; CHECK:   store i66 %X, i66* @G
+; CHECK:   ret void
+; CHECK: }
+; CHECK: define i66 @bar() {
+; CHECK:   %V = load i66, i66* @G
+; CHECK:   %C = icmp eq i66 %V, 17
+; CHECK:   br i1 %C, label %T, label %F
+; CHECK: T:
+; CHECK:   store i66 17, i66* @G
+; CHECK:   ret i66 %V
+; CHECK: F:
+; CHECK:   store i66 123, i66* @G
+; CHECK:   ret i66 0
+; CHECK: }
 
+ at G = internal global i66 undef
 
 define void @foo() {
 	%X = load i66, i66* @G
Index: lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- lib/Transforms/Scalar/SCCP.cpp
+++ lib/Transforms/Scalar/SCCP.cpp
@@ -1504,9 +1504,8 @@
 
       // Otherwise, it is a branch on a symbolic value which is currently
       // considered to be undef.  Handle this by forcing the input value to the
-      // branch to false.
-      markForcedConstant(BI->getCondition(),
-                         ConstantInt::getFalse(TI->getContext()));
+      // branch to overdefined.
+      markOverdefined(BI->getCondition());
       return true;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26432.77287.patch
Type: text/x-patch
Size: 2116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161109/d49c981e/attachment.bin>


More information about the llvm-commits mailing list