[llvm] 10cee82 - [Test] Add test exposing hoisting bug in GuardWidening (NFC)

Dmitry Makogon via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 00:08:56 PST 2023


Author: Dmitry Makogon
Date: 2023-02-28T15:08:32+07:00
New Revision: 10cee821202b17ba4da6ed36ac3101a1ae81fdcd

URL: https://github.com/llvm/llvm-project/commit/10cee821202b17ba4da6ed36ac3101a1ae81fdcd
DIFF: https://github.com/llvm/llvm-project/commit/10cee821202b17ba4da6ed36ac3101a1ae81fdcd.diff

LOG: [Test] Add test exposing hoisting bug in GuardWidening (NFC)

It hoits instruction without making sure its operands are
available at hoisiting point.

Added: 
    llvm/test/Transforms/GuardWidening/widen-cond-with-operands.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/GuardWidening/widen-cond-with-operands.ll b/llvm/test/Transforms/GuardWidening/widen-cond-with-operands.ll
new file mode 100644
index 0000000000000..398956e6c9350
--- /dev/null
+++ b/llvm/test/Transforms/GuardWidening/widen-cond-with-operands.ll
@@ -0,0 +1,40 @@
+; RUN: opt -S -passes=guard-widening,verify < %s | FileCheck %s
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
+target triple = "x86_64-unknown-linux-gnu"
+
+; REQUIRES: asserts
+; XFAIL: *
+
+; GuardWidening moves 'check' instruction before 'wc1' without its operand ('zero').
+; This is incorrect as 'zero' is not available at that point.
+define void @foo() {
+bb:
+  %wc1 = call i1 @llvm.experimental.widenable.condition()
+  %wc2 = call i1 @llvm.experimental.widenable.condition()
+  %zero = add i32 0, 0
+  %check = icmp ult i32 %zero, 0
+  %c1 = and i1 %check, %wc1
+  %c2 = and i1 %check, %wc2
+  br i1 %c1, label %bb6, label %bb9
+
+bb6:                                              ; preds = %bb
+  br i1 %c2, label %bb7, label %bb8
+
+bb7:                                              ; preds = %bb6
+  ret void
+
+bb8:                                              ; preds = %bb6
+  call void (...) @llvm.experimental.deoptimize.isVoid(i32 0) [ "deopt"() ]
+  ret void
+
+bb9:                                              ; preds = %bb
+  call void (...) @llvm.experimental.deoptimize.isVoid(i32 0) [ "deopt"() ]
+  ret void
+}
+
+declare void @llvm.experimental.deoptimize.isVoid(...)
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite)
+declare i1 @llvm.experimental.widenable.condition() #0
+
+attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(inaccessiblemem: readwrite) }


        


More information about the llvm-commits mailing list